messenger-ruby ArgumentError(缺少关键字:payload)

时间:2017-01-23 16:41:55

标签: ruby-on-rails facebook

升级到messenger-ruby gem的1.2.0版本后,我用它来获取Facebook Messenger用户在快速回复中的位置,看来messenger-ruby无法解析返回的位置附件对象。在我有机会发回200 OK响应之前发生此错误,以便控制器挂断。我该如何解决这个问题?

以下是heroku日志文件的片段:

2017-01-23T03:15:52.544541+00:00 app[web.1]: Started POST "/messenger/webhook" for 173.252.123.140 at 2017-01-23 03:15:52 +0000
2017-01-23T03:15:52.547400+00:00 app[web.1]: Processing by MessengerController#webhook as */*
2017-01-23T03:15:52.547618+00:00 app[web.1]:   Parameters: {"object"=>"page", "entry"=>[{"id"=>"776445229159135", "time"=>1485141352448, "messaging"=>[{"sender"=>{"id"=>"938332056296353"}, "recipient"=>{"id"=>"776445229159135"}, "timestamp"=>1485120971441, "message"=>{"mid"=>"mid.1485120971441:34f1a70557", "seq"=>3197, "attachments"=>[{"title"=>"James's Location", "url"=>"url redacted", "type"=>"location", "payload"=>{"coordinates"=>{"lat"=>36.074067028043, "long"=>-95.645990201969}}}]}}]}], "messenger"=>{"object"=>"page", "entry"=>[{"id"=>"776445229159135", "time"=>1485141352448, "messaging"=>[{"sender"=>{"id"=>"938332056296353"}, "recipient"=>{"id"=>"776445229159135"}, "timestamp"=>1485120971441, "message"=>{"mid"=>"mid.1485120971441:34f1a70557", "seq"=>3197, "attachments"=>[{"title"=>"James's Location", "url"=>"url redacted, "type"=>"location", "payload"=>{"coordinates"=>{"lat"=>36.074067028043, "long"=>-95.645990201969}}}]}}]}]}}
2017-01-23T03:15:52.549321+00:00 app[web.1]: Completed 500 Internal Server Error in 2ms (ActiveRecord: 0.0ms)
2017-01-23T03:15:52.549885+00:00 app[web.1]:
2017-01-23T03:15:52.549888+00:00 app[web.1]:   app/controllers/messenger_controller.rb:8:in `webhook'
2017-01-23T03:15:52.549887+00:00 app[web.1]: ArgumentError (missing keyword: payload)

1 个答案:

答案 0 :(得分:0)

更新:我不确定发生了什么,但我做了一些调试,这开始工作了。我复制了Facebook发送给我的对象,并在从github克隆宝石后打开了一个控制台,完全没有问题!