Bre*_*ett 3 twilio firebase google-cloud-functions twilio-api
我正在关注有关如何使用我的应用程序回复短信的 Twilio 教程: https://www.twilio.com/docs/sms/tutorials/how-to-receive-and-reply-node-js
本教程假设您使用的是 Express,但我使用 Cloud Function 执行此操作,因此我的代码看起来有点不同:
exports.sms = functions.https.onCall((req: any, res: any) => {
const twiml = new MessagingResponse();
if (req.body.Body === 'hello') {
twiml.message('Hi!');
} else if (req.body.Body === 'bye') {
twiml.message('Goodbye');
} else {
twiml.message(
'No Body param match, Twilio sends this in the request to your server.',
);
}
res.writeHead(200, { 'Content-Type': 'text/xml' });
res.end(twiml.toString());
});
Run Code Online (Sandbox Code Playgroud)
当我向 Twilio # 发送短信时,它会到达该端点,但出现以下错误:
请求的内容类型不正确。应用程序/x-www-form-urlencoded
我该如何解决这个问题?
| 归档时间: |
|
| 查看次数: |
1361 次 |
| 最近记录: |