Twilio得到错误代码短信发送失败

问题描述:

我们的代码通过执行以下操作将twilio短信:Twilio得到错误代码短信发送失败

// get the twilio error components 
$twilio_error_status = $e->getStatus(); 
$twilio_error_code = $e->getCode(); 
$twilio_error_msg = $e->getMessage(); 

// send the text message to the member's mobile phone 
try { 

// attempt to send the message through Twilio 
$tw_msg = $twilio_client->messages->create(
    "+1".$recipient['address'], 
    array (
     'From' => "+1".$org['twilio_number'], 
     'Body' => $txtmsg, 
     'StatusCallback' => CALLBACK_LINK.'/text_message_handler.php' 
    ) 
); 

// else trap the error since the message could not be sent and the callback routine is not called 
} catch (Exception $e) { 

    // process the text message error 
    process_text_msg_error($db, $e, $org, $msg, $recipient); 
} 

在V4库,我们将通过执行以下操作,出现错误代码

这并没有给我们预期使用V5库。我们如何使用V5 lib获取错误状态和代码?

+0

当您处理错误时,您使用v5库获得了什么? – philnash

+0

这是一个数组,我将不得不通过电子邮件发送给您。 – Tim

Twilio开发者传道这里。

它看起来像我需要更新您调用异常的方法之一来获取状态码。现在例外是RestException并且具有方法getStatusCode()。你应该更新到:

// get the twilio error components 
$twilio_error_status = $e->getStatusCode(); 
$twilio_error_code = $e->getCode(); 
$twilio_error_msg = $e->getMessage(); 

让我知道这是否有帮助。

+0

是的,这给了我们400码。其他两个领域怎么样,我们如何得到这些?我们想要特定的5位数的错误代码。 400仅表示https请求未能创建消息。 – Tim

+0

“getCode”和“getMessage”方法是否不给出5位错误代码? – philnash

+0

我的不好!他们正在工作,我没有将他们添加到日志文件。朋友,谢谢。 – Tim