Facebook bot -Manipular url de Imagens E Arquivos Anexados

发布于 2025-02-07 08:52:42 字数 650 浏览 0 评论 0原文

将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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

乖乖 2025-02-14 08:52:42

attactment.payload.url属性中的URL可公开访问。因此,您可以下载文件服务器端。由于您只需要找出文件名和MIME类型,因此只能执行 head请求由于您需要的所有数据都在标题中,尤其是对于此文件:(

content-disposition: inline;filename=image-2608864215911984
content-type: image/jpeg

使用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:

content-disposition: inline;filename=image-2608864215911984
content-type: image/jpeg

(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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文