Facebook bot -Manipular url de Imagens E Arquivos Anexados
将Facebook聊天中的媒体类型发送到具有机器人的页面时,我会得到以下响应:
"recipient":{
sender: { id: 'xxxx' },
recipient: { id: 'xxxx' },
timestamp: xxx,
},
"message":{
"attachment":{
"type":"image",
"payload":{
"url":"https://lookaside.fbsbx.com/ig_messaging_cdn/?asset_id=2608864215911984&signature=AbykSEBb24Mq3HE0VzWv_XLb9klY3_7hiZauQp_DxjPbHGbEz_-N4r7Rf_7dxNM2v3yzzy0sIGvKFuiFxvCrvVAybrBa5omgAADBhtHnJMJk3TMqGnmrlIa5mmnaJ1nfQSFT1q0hQrTyVzl81gxGEOEl5AFwzVINKWeY_J-_0Oxb1qxHOrjnUgdFQNS_rGLa4QiNs0wkRk9OXOHlVtEy5sFxUqPY7Q"
}
}
}
}
如何获得文件名 + MIME类型?还是如何通过此类型的URL下载此文件?
我尝试下载,但文件已损坏
When sending a media type in facebook chat to a page that has a bot, I get the following response:
"recipient":{
sender: { id: 'xxxx' },
recipient: { id: 'xxxx' },
timestamp: xxx,
},
"message":{
"attachment":{
"type":"image",
"payload":{
"url":"https://lookaside.fbsbx.com/ig_messaging_cdn/?asset_id=2608864215911984&signature=AbykSEBb24Mq3HE0VzWv_XLb9klY3_7hiZauQp_DxjPbHGbEz_-N4r7Rf_7dxNM2v3yzzy0sIGvKFuiFxvCrvVAybrBa5omgAADBhtHnJMJk3TMqGnmrlIa5mmnaJ1nfQSFT1q0hQrTyVzl81gxGEOEl5AFwzVINKWeY_J-_0Oxb1qxHOrjnUgdFQNS_rGLa4QiNs0wkRk9OXOHlVtEy5sFxUqPY7Q"
}
}
}
}
how can i get the filename + the mime type? or how can I download this file by this type of url?
I tried to download but the file is corrupted
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
attactment.payload.url
属性中的URL可公开访问。因此,您可以下载文件服务器端。由于您只需要找出文件名和MIME类型,因此只能执行 head请求由于您需要的所有数据都在标题中,尤其是对于此文件:(使用
curl -i
获得),请注意,您可能不会收到原始的原始文件名,因为此信息未从Facebook的CDN提供。如果这是一个文件,您可以通过附件上传api ,您可以从上传时提供的URL推断文件名。
The URL in
attachment.payload.url
property is publicly accessible. Therefore, you can download the file server-side. Since you only need to find out the filename and MIME type, you can perform only a HEAD request since all data you need are in the headers, notably, for this file:(Obtained with
curl -I
)Mind that you probably won't receive the original filename, as this information is not provided from Facebook's CDN. If this is a file you uploaded via the attachment upload API, you could infer the filename from the URL provided on upload.