How to get notified when SMS Status changes from 'Queued' to 'Sent'?

↘锁芯ラ 提交于 2019-12-18 19:17:27

问题


Hello,
I am trying to learn Twilio API.
When I [send SMS through php][1] script.. twilio returns a response object with status = 'queued'. Now I want to get notified when the status changes to 'sent'. Is this possible with Twilio??? and if yes then could any body advise me on how to implement his.

And how to add 'StatusCallback' url

$sms = $client->account->sms_messages->create(
            // the number we are sending from, must be a valid Twilio number
            "000-000-0000", 

            // the number we are sending to - Any phone number
            "0000000000",

            // the sms body
            "Hey Friend, Monkey Party at 6PM. Bring Bananas!"
        );

回答1:


You're on the right track looking to the StatusCallback. When using the Twilio PHP Library any optional parameters can be set using an array as the last argument.

<?php
$sms = $client->account->sms_messages->create(
  "1235551234", 
  "1235554321",
  "Hey Friend, Monkey Party at 6PM. Bring Bananas!",
  array('StatusCallback' => 'http://example.com/sms/status.php')
);

When the message is sent (or if it fails) the data will be passed to the StatusCallback url.



来源:https://stackoverflow.com/questions/9430003/how-to-get-notified-when-sms-status-changes-from-queued-to-sent

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!