2017-07-24 123 views
0

我們的代碼通過執行以下操作將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

回答

1

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