Facebook Messenger API: “Failed to fetch the file

2019-07-30 14:12发布

I am currently attempting to send a hosted image as an attachment using the Facebook Messenger Send API. I make a POST request like the following:

{"message": {"attachment": {"payload": {"url": "http://url.com/image"},
                            "type": "image"}},
 "recipient": {"id": 129760000000000}}

When I access the given URL using a browser, it displays the image. However, the API always returns an error:

{'error': {'code': 100,
           'type': 'OAuthException',
           'fbtrace_id': 'GlCkjxuGMw0',
           'error_subcode': 2018008,
           'message': '(#100) Failed to fetch the file from the url'}}

How can I fix this error? Any help is very appreciated!

2条回答
Deceive 欺骗
2楼-- · 2019-07-30 14:53

For people who may stumble on this question later, I managed to work out the source of the issue. There is an inbuilt file limit for Messenger attachments, and this image (2MB) was over it. Retrying with a smaller image was successful. However, the Messenger documentation unfortunately does not specify the limit, so it's down to guesswork!

查看更多
叛逆
3楼-- · 2019-07-30 14:58

I had the same problem, my facebook bot was in flask python and solved it by adding "threaded=True" to my app.run.

if name == 'main': app.run(host='127.0.0.1', port=5000, debug=True, threaded=True)

查看更多
登录 后发表回答