How to make sure a SMS went through after sending it with Twilio

纵饮孤独 提交于 2020-01-02 07:12:19

问题


I am using the Twilio java wrapper provided on the website and started making some tests. I am able to send text messages that are successfully received. However, I would like to make sure that the messages have been sent successfully and that no problem has been encountered by Twilio (bad phone number or whatever reason).

I understand that when you make a REST request to Twilio to send a SMS, Twilio responds with the Status. How could I get this response?

Here is the explanation page I found: http://www.twilio.com/docs/howto/sms-notifications-and-alerts


回答1:


If you specify a StatusCallback URL when you make the request to send an SMS, we will make a request to the callback URL you provided after the message has finished processing, with the parameters either SmsStatus=sent or SmsStatus=failed. You can use this information to do more processing on the SMS message. There's more information here: http://www.twilio.com/docs/api/rest/sending-sms#post-parameters-optional

Alternately, if you hang on to the SMS Message Sid, you should be able to query the API for the message and get the status in the response. So if the sid is SM123, making a GET request to https://api.twilio.com/2010-04-01/Accounts/AC123/SMS/Messages/SM123.json should return a object with the status of the SMS Message.




回答2:


I recall that the response comes to your url and can be matched up by an ID. In the REST post to SMSMessages you can specify a statuscallback url where Twilio will post a status message to your url.

When you receive that post to your site, you can record it or take any other action you need, such as retrying or using another mode of communication.



来源:https://stackoverflow.com/questions/10554138/how-to-make-sure-a-sms-went-through-after-sending-it-with-twilio

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