2017-08-11 96 views
0

我正在使用Twilio服務向我的應用程序中的不同類型的用戶發送消息。現在消息日誌顯示所有正確列出的消息,但是我可以添加一個可選參數來標識發送給不同用戶的一組不同的消息。 用戶是否允許使用Twilio消息日誌的自定義參數來基於此參數識別/過濾消息?用戶自定義參數是否允許使用twilio?

如果我的思維方式錯了,是否有解決方案來分類或識別發送給特定人羣的特定消息組?

for ($i = 0; $i < count($mobile_numbers); $i++) 
      { 
       $mobile_number = $mobile_numbers[$i]; 
       $otp_message_result = json_decode(send_text_message($mobile_number, $custom_message)); 
       $msg_sid = $otp_message_result -> sid; 
       $msg_status = $otp_message_result -> status; 
} 
+0

不知道你的代碼示例應該代表什麼,你能解釋一下嗎?你真的想在這裏做什麼? – philnash

+0

@philnash 發送消息時,我可以發送一個額外的參數,如customer_id,以便我可以基於此參數篩選Twilio中的消息日誌。 –

回答

0

Twilio開發者傳道這裏。

Twilio API中沒有用於保存自己的數據的自定義字段。

如果你想find all the messages sent to one telephone number那麼你可以通過這個數字過濾,像這樣:

use Twilio\Rest\Client; 

// Your Account Sid and Auth Token from twilio.com/user/account 
$sid = "your_account_sid"; 
$token = "your_auth_token"; 
$client = new Client($sid, $token); 

$phone_number = PHONE_NUMBER; 

// Loop over the list of messages and echo a property for each one 
foreach ($client->messages->read(array("To" => $phone_number)) as $message) { 
    echo $message->body; 
} 

如果您需要任何更具體的,那麼我建議你保存你發來的短信中的SID每個用戶到你自己的數據庫。

相關問題