无法从Twilio请求获取GET数据

时间:2016-02-28 14:19:27

标签: node.js rest meteor twilio body-parser

编辑。

再一次,我不知道如何解决这个问题(简单,我确定)。也许你可以告诉我一条道路..:我无法得到休息GET请求的“正文”。

更确切地说:

  1. 我从手机发送短信到我的Twilio号码
  2. 此入站邮件“触发”从Twilio到我的应用程序的请求URL(http get)
  3. 我的应用服务器“捕获”数据(邮件正文,发件人,时间戳...)并“重新启动”确认短信...
  4. 超级简单!

    • (1)没有问题 - >希望!
    • (2)
    • 没问题
    • 但是,使用(3),确认短信发送良好,但我无法访问数据(我的终端中的日志总是显示两个空的括号...)

    知道发生了什么事吗?

    非常感谢..

      var bodyParser = Meteor.npmRequire( 'body-parser' );
    
    Picker.middleware( bodyParser.json() );
    Picker.middleware( bodyParser.urlencoded( { extended: false } ) );
    
    Picker.route( '/documents', function( params, request, response, next ) {
    
        if (client.findOne({_id:"EJB3KDgTwBzvoe3y6"})){
            console.log("blabla");
            // with just 'params' I get something verbose in my terminal, including my message, but I don't know how to 'catch' it
            console.log( request.body );
            // messages.insert({
            //     message: request....
            // });
            response.setHeader( 'Content-Type', 'application/xml' );
            response.statusCode = 200;
            response.end( "<Response><Message>Bonjour, I'm becky</Message></Response>" );
        }
    
        else {
            response.setHeader( 'Content-Type', 'application/xml' );
            response.statusCode = 200;
            response.end( "<Response><Message>Hello, don't knou you..</Message></Response>" );
        }
    });
    

    编辑2: 这就是我在终端(流星)中得到的内容

    I20160228-16:53:22.209(1)? { query: 
    I20160228-16:53:22.210(1)?    { ToCountry: 'FR',
    I20160228-16:53:22.210(1)?      ToState: '',
    I20160228-16:53:22.210(1)?      SmsMessageSid: 'SMf8eae81eb0f2bd',
    I20160228-16:53:22.210(1)?      NumMedia: '0',
    I20160228-16:53:22.210(1)?      ToCity: '',
    I20160228-16:53:22.210(1)?      FromZip: '',
    I20160228-16:53:22.210(1)?      SmsSid: 'SMf8eae81eb0f2bd',
    I20160228-16:53:22.210(1)?      FromState: '',
    I20160228-16:53:22.211(1)?      SmsStatus: 'received',
    I20160228-16:53:22.211(1)?      FromCity: '',
    I20160228-16:53:22.211(1)?      Body: 'my message I want to catch and store in my db',
    I20160228-16:53:22.211(1)?      FromCountry: 'FR',
    I20160228-16:53:22.211(1)?      To: '+xxxxxxxxxxxxxx',
    I20160228-16:53:22.211(1)?      ToZip: '',
    I20160228-16:53:22.211(1)?      NumSegments: '1',
    I20160228-16:53:22.211(1)?      MessageSid: 'SMf8eae81eb',
    I20160228-16:53:22.211(1)?      AccountSid: 'AC72924a656',
    I20160228-16:53:22.211(1)?      From: '+xxxxxxxxxxxxx',
    I20160228-16:53:22.212(1)?      ApiVersion: '2010-04-01' } }
    

0 个答案:

没有答案