铁路由器:逃离'?'在传入的Twilio消息中

时间:2016-04-28 16:44:21

标签: meteor twilio iron-router

这可能很简单,但我无法找到任何直接答案:

我正在写一个机器人来回答通过短信提出的问题。 Twilio将问题路由到webhook,我提取邮件正文和发件人的电话号码以准备回复。当SMS正文不包含?时(如大多数问题那样),这种方法很有效。如果是,请求在?之后被截断,我无法读取数字字段。

示例:

Router.route('/twilio/', function() {
  console.log('%j', this.params.query);
  var number = this.params.query.From;
  var body = this.params.query.Body;
  var args = {
    number: number,
    message: body
  }
  this.response.end(Meteor.call('sendMessage', args));
}, {
  where: 'server'
});

以下是?询问问题时的日志(例如"您今天做得怎么样?")

{"ToCountry":"US","ToState":"MI","SmsMessageSid":"SM7bb1aee8c38c567e916c715672b5a201","NumMedia":"0","ToCity":"OXFORD","FromZip":"07950","SmsSid":"SM7bb1aee8c38c567e916c715672b5a201","FromState":"NJ","SmsStatus":"received","FromCity":"CALDWELL","Body":"How are you doing today"}

这里没有?(例如"你今天做得怎么样")

{"ToCountry":"US","ToState":"MI","SmsMessageSid":"SM00d6a0c1bfec40c2372ed2cc255af918","NumMedia":"0","ToCity":"OXFORD","FromZip":"07950","SmsSid":"SM00d6a0c1bfec40c2372ed2cc255af918","FromState":"NJ","SmsStatus":"received","FromCity":"CALDWELL","Body":"How are you doing today","FromCountry":"US","To":"+1xxxxxxxxxx","ToZip":"48367","NumSegments":"1","MessageSid":"SM00d6a0c1bfec40c2372ed2cc255af918","AccountSid":"ACc8f77bee1430f42600b6f83d7174384c","From":"+1234567890","ApiVersion":"2010-04-01"}

我无法找到让Twilio编码GET请求的方法。除非有一种方法让Iron Router在消息体内转义特殊字符? 如果没有,是转换为POST请求的唯一解决方案吗?

谢谢!

0 个答案:

没有答案