twilio允许用户自定义参数吗?

时间:2017-08-11 12:20:44

标签: twilio twilio-api twilio-php

我正在使用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;
}

1 个答案:

答案 0 :(得分: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保存到您自己的数据库中。