Home > Net >  facebook bot - manipular url de imagens e arquivos anexados
facebook bot - manipular url de imagens e arquivos anexados

Time:06-28

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

CodePudding user response:

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.

  • Related