[英]how to serve Twiml Nodejs
我很難用 nodejs 創建我的 TWIML 文件。 我正在創建出站調用,它們使用靜態 XML 文件或 twiml bin 但不適用於我的端點。
你知道有什么問題嗎?
app.post('/twiml-generator', function(req, res){
var name = "billy";
//Create TwiML response
var twiml = new twilio.TwimlResponse();
twiml.say("Hello from your pals at Twilio! Have fun. Love " + name);
res.writeHead(200, {'Content-Type': 'text/xml'});
res.end(twiml.toString());
});
然后當我去發起呼叫時
client.calls.create({
url: 'http://myHOSTEDsite.com/twiml-generator',//ISSUE HERE but if i use a twiml bin or static xml, it works// so my endpoint must be the issue
to: targetNumber,
from: "+14444444444", // my trail number
timeout: 12
}, function(err, call) {
console.log("call made");
//console.log(call)
});
代替
res.writeHead(200, {'Content-Type': 'text/xml'});
res.end(twiml.toString());
嘗試
res.set('Content-Type', 'text/xml');
res.send(twiml.toString());
這就是 Twilio 文檔所說的
response.type('text/xml');
response.send(twiml.toString());
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.