Twilio webhook sms response format

只谈情不闲聊 提交于 2019-12-30 22:55:45

问题


I'm using Twilio with my app and I have sms webhooks with my SMS numbers configured with URL. Everything is working except that Twilio send me an error in logs for each requests. I suppose that the response from my app is not well formated but I can't find on documentation how to format using JSON.

Can someone help me ? :)

Thanks, Gabriel


回答1:


Twilio developer evangelist here.

When you return a webhook message to Twilio, you need to make sure it's valid TwiML, which in essence is just a set of XML verbs Twilio uses.

If you're responding to an SMS message for example, you would return TwiML as follows:

<?xml version="1.0" encoding="UTF-8"?>
<Response>
    <Message>Thanks for getting in touch, I'll call you later</Message>
</Response>

You can test the code above by changing the configuration of your number to point to this url and you should stop seeing the errors.

If you generating the TwiML yourself, you need to make sure that the page's MIME type is text/xml.

Hope this helps you out.



来源:https://stackoverflow.com/questions/36792254/twilio-webhook-sms-response-format

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