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获取错误状态和代码?
答
Twilio开发者传道这里。
它看起来像我需要更新您调用异常的方法之一来获取状态码。现在例外是RestException
并且具有方法getStatusCode()
。你应该更新到:
// get the twilio error components
$twilio_error_status = $e->getStatusCode();
$twilio_error_code = $e->getCode();
$twilio_error_msg = $e->getMessage();
让我知道这是否有帮助。
当您处理错误时,您使用v5库获得了什么? – philnash
这是一个数组,我将不得不通过电子邮件发送给您。 – Tim