Gif没有发送facebook messenger Bot

时间:2017-01-25 13:34:05

标签: facebook-messenger

您好我正在尝试在FB Messenger中发送一个gif。我的代码如下

        function sendGif(sender) {
            let messageData = {
                "attachment": {
                    "type": "image",
                    "payload": {
                        "url": "http://giphy.com/gifs/tom-cruise-risky-business-movie-3jzoNumaV4o80",
                    }
                }
            }
            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)
                }
            })
        }

但是,我得到这个错误告诉我我正在尝试附加的文件现在被允许并且具有不同的格式

2017-01-25T13:27:53.586498+00:00 app[web.1]: Error:  { message: '(#546) The type of file you\'re trying to attach isn\'t allowed. Please try again with a different format.',
2017-01-25T13:27:53.586508+00:00 app[web.1]:   type: 'OAuthException',
2017-01-25T13:27:53.586509+00:00 app[web.1]:   code: 546,
2017-01-25T13:27:53.586510+00:00 app[web.1]:   error_subcode: 1545026,
2017-01-25T13:27:53.586511+00:00 app[web.1]:   fbtrace_id: 'BN+U/mDnnMi' }

我做错了什么?

1 个答案:

答案 0 :(得分:2)

您正在尝试发送Kids.__iter__文件,而非gif。

gif的网址是:

https://media.giphy.com/media/3jzoNumaV4o80/giphy.gif