【问题标题】:how to serve Twiml Nodejs如何为 Twiml Nodejs 提供服务
【发布时间】:2017-02-19 02:46:39
【问题描述】:

我很难用 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)

  }); 

【问题讨论】:

    标签: javascript node.js twilio twilio-api twilio-twiml


    【解决方案1】:

    代替

    res.writeHead(200, {'Content-Type': 'text/xml'});
    res.end(twiml.toString());
    

    试试

    res.set('Content-Type', 'text/xml');
    res.send(twiml.toString());
    

    【讨论】:

      【解决方案2】:

      这是 Twilio 文档所说的

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-07-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-03-10
        • 2017-04-08
        • 2020-07-01
        • 2017-03-24
        相关资源
        最近更新 更多