Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何服务Twiml节点_Javascript_Node.js_Twilio_Twilio Api_Twilio Twiml - Fatal编程技术网

Javascript 如何服务Twiml节点

Javascript 如何服务Twiml节点,javascript,node.js,twilio,twilio-api,twilio-twiml,Javascript,Node.js,Twilio,Twilio Api,Twilio Twiml,我很难用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 pa

我很难用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());
试一试


这是Twilio医生说的

response.type('text/xml');
response.send(twiml.toString());
response.type('text/xml');
response.send(twiml.toString());