问题描述
这是我的情况:我正在使用Twilio将SMS发送给我的客户.当用户决定不接收这些SMS时,他们将回复STOP(停止)和START(开始)以再次接收.这由Twilio自动处理.但是,我需要调用AWS Lambda函数并相应地更新数据库.
Here is my scenario: I am using Twilio to send SMSes to my clients. When user decides not to receive these SMSes they reply STOP and START to receive again. This is automatically handled by Twilio. But, i need to invoke a AWS Lambda function and update my database accordingly.
这是我到目前为止所做的:1.我创建了一个TwiML应用程序2.我已将此TwilML应用添加到我的Twilio号码中.3.创建一个Lambda函数和API网关.在TwiML应用程序中添加了端点.
This is what i am doing till now:1. I have created a TwiML App2. I have added this TwilML App to my Twilio number.3. Created a Lambda Function and API Gateway. Added the end-point in TwiML App.
将AWS Lambda-API网关添加到TwiML App
Adding AWS Lambda - API Gateway to TwiML App
将TwiML应用程序添加到我的Twilio电话号码中
Adding TwiML App to my Twilio Phone Number
我收到的SMS日志说用户已经从他的电话号码发送了START/STOP,但是Lambda函数没有被调用.
I am getting the SMS Logs saying that the user has sent START/STOP from his phone number, but, the Lambda function is not getting invoked.
这是Twilio的SMS日志:
Here is the SMS Log from Twilio:
有人可以帮助我了解问题出在哪里吗?响应为不受支持的媒体类型"是什么意思?
Can someone help me understand what's going wrong? And what it means when the response is "Unsupported media type"?
推荐答案
如果您使用的是 Java代码(用于您的TwiML应用),您是否已为TwiML指定了XML内容类型,例如:
If you're using Java code for your TwiML app, have you specified the XML content type for TwiML as such:
response.setContentType("application/xml");
response.getWriter().print(twiml.toXML());
这可能是少数原因之一,如注释的链接中所述.
That could be one of a handful of causes as explained in the link from the comments.
这篇关于TwiML应用程序-当用户回复STOP/START以获取Twilio编号时,调用AWS Lambda的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!