2017-08-11 90 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每个用户到你自己的数据库。

相关问题