如何在 node.js 中创建有效的 TwilioML 响应对象
How to create a valid TwilioML response object in node.js
我有一个 twilio webhook,我正在尝试根据 twiloML 构建响应,我在
的 twilio 日志中收到错误响应
12200 The provided XML does not conform to the Twilio Markup XML
schema. Please refer to the specific error and correct the problem.
const twilio = require('twilio');
function defaultTwilioSuccess(){
var response = new twilio.twiml.MessagingResponse();
response.message('its alive');
return response.toString();
}
exports.handler = function(event, context, callback){
...
.then(function() {
return callback(null, {
"statusCode": 200,
"headers": {'Content-Type': 'text/xml'},
"body": JSON.stringify(defaultTwilioSuccess())
});
});
...
JSON.stringify
在这种情况下不需要,因为它的响应是 XML 格式
return callback(null, {
"statusCode": 200,
"headers": {'Content-Type': 'text/xml'},
"body": defaultTwilioSuccess()
});
});
我有一个 twilio webhook,我正在尝试根据 twiloML 构建响应,我在
的 twilio 日志中收到错误响应12200 The provided XML does not conform to the Twilio Markup XML schema. Please refer to the specific error and correct the problem.
const twilio = require('twilio');
function defaultTwilioSuccess(){
var response = new twilio.twiml.MessagingResponse();
response.message('its alive');
return response.toString();
}
exports.handler = function(event, context, callback){
...
.then(function() {
return callback(null, {
"statusCode": 200,
"headers": {'Content-Type': 'text/xml'},
"body": JSON.stringify(defaultTwilioSuccess())
});
});
...
JSON.stringify
在这种情况下不需要,因为它的响应是 XML 格式
return callback(null, {
"statusCode": 200,
"headers": {'Content-Type': 'text/xml'},
"body": defaultTwilioSuccess()
});
});