Twilio Webhook短信响应格式 [英] Twilio webhook sms response format
问题描述
我在我的应用程序中使用了Twilio,并且我的SMS Webhooks的SMS号码配置了URL. 一切正常,除了Twilio向我发送每个请求的日志错误. 我想我的应用程序的响应格式不正确,但是我在文档中找不到如何使用JSON进行格式设置.
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 ? :)
谢谢, 加布里埃尔
推荐答案
此处是Twilio开发人员的福音.
Twilio developer evangelist here.
当您将Webhook消息返回给Twilio时,您需要确保其有效 TwiML ,从本质上讲,这只是Twilio使用的一组XML动词.
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.
例如,如果您正在响应SMS消息,则将返回TwiML,如下所示:
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.
如果您自己生成TwiML,则需要确保页面的MIME类型为text/xml.
If you generating the TwiML yourself, you need to make sure that the page's MIME type is text/xml.
希望这对您有所帮助.
这篇关于Twilio Webhook短信响应格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!