Facebook Messenger API: “Failed to fetch the file from the url” when the file exists

China☆狼群 提交于 2019-12-24 07:05:41

问题


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!


回答1:


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!




回答2:


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)



来源:https://stackoverflow.com/questions/41436779/facebook-messenger-api-failed-to-fetch-the-file-from-the-url-when-the-file-ex

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!