2016-02-05 71 views
0

我想获取输入手机的数字。我想在引脚功能res.Digits会的方式,但我得到一个未定义的错误从twilio收集数字收集

exports.Say = function(req, res) 
{ 
    var resp = new twilio.TwimlResponse(); 

    resp.gather(
    { 
     action:'http://pap-papdemo.rhcloud.com/api/Phone/Pin', 
     finishOnKey:'#', 
     method:"POST" 
    }, function() 
    { 
     this.say('Please enter your Phone and Pin number followed by the hash key'); 
    }); 

    //Render the TwiML document using "toString" 
    res.writeHead(200, 
    { 
      'Content-Type':'text/xml' 
    }); 

    res.end(resp.toString()); 

}; 




    exports.Pin = function(req, res) 
     { 
      var resp = new twilio.TwimlResponse(); 
      console.log("***** PIN *****"); 


      console.log("Pin: Response " + res.body.Digits); 

      //Render the TwiML document using "toString" 
      res.writeHead(200, 
      { 
        'Content-Type':'text/xml' 
      }); 

      res.end(resp.toString()); 

     }; 

任何知道我需要做的,因为我需要存储针数分贝

+0

我看到数字是在请求参数,所以尝试req.params.Digits但没有工作 – ActionManning

+0

我最终得到了答案var pin = JSON.stringify(req.body.Digits); – ActionManning

回答

0

梅根从Twilio这里。我看到你回答了你自己的问题,但认为我会更新为其他人登陆的答案。

Twilio will pass Digits as a parameter除了标准TwiML语音请求参数以及对'action'URL的请求。

因此var pin = JSON.stringify(req.body.Digits);在这种情况下工作。