0

我正在尝试快速回复 facebook messenger - 在下面收到此错误:

2017-01-22T04:18:40.538348+00:00 app[web.1]: Error:  { message: '(#100) Invalid keys "message" were found in param "message".',
2017-01-22T04:18:40.538359+00:00 app[web.1]:   type: 'OAuthException',
2017-01-22T04:18:40.538361+00:00 app[web.1]:   code: 100,
2017-01-22T04:18:40.538361+00:00 app[web.1]:   fbtrace_id: 'F9umRNKYj+/' }
2017-01-22T04:18:40.907028+00:00 app[web.1]: Error:  { message: '(#100) Invalid keys "message" were found in param "message".',
2017-01-22T04:18:40.907040+00:00 app[web.1]:   type: 'OAuthException',

这是我在下面使用的代码 - 我从他们的开发者网站中提取的示例 facebook 代码。

function startUpMenu(sender) {
            let messageData = {
                "message":{
                   "text":"Pick a color:",
                   "quick_replies":[{
                       "content_type":"text",
                       "title":"Red",
                       "payload":"RedText"
                      },
                      {
                        "content_type":"text",
                        "title":"Green",
                        "payload":"GreenText"
                      }]
                }               
            }
            request({
                url: 'https://graph.facebook.com/v2.6/me/messages',
                qs: {access_token:token},
                method: 'POST',
                json: {
                    recipient: {id:sender},
                    message: messageData,
                }
            }, function(error, response, body) {
                if (error) {
                    console.log('Error sending messages: ', error)
                } else if (response.body.error) {
                    console.log('Error: ', response.body.error)
                }
            })
        }

请问有谁知道如何解决这个问题?

4

2 回答 2

0

我相信答案是由@WizKid提供的,可以关闭。

json: {
    recipient: {id:sender},
    message: messageData.message
}
于 2017-01-27T12:11:34.987 回答
0
 function startUpMenu(sender) {
        let messageData = {
                 recipient:{
             id:sender
            },
            "message":{
               "text":"Pick a color:",
               "quick_replies":[{
                   "content_type":"text",
                   "title":"Red",
                   "payload":"RedText"
                  },
                  {
                    "content_type":"text",
                    "title":"Green",
                    "payload":"GreenText"
                  }]
            }               
        }

我希望在您的代码中进行此更改将消除错误。

于 2017-02-28T11:06:32.383 回答