fbbotw.upload_reusable_attachment

fbbotw.upload_reusable_attachment(media_url, file_type)[source]

Uploads an attachment to be used later. You can optimize sending multimedia by reusing attachments. If you’re sending the same attachments repeatedly, you should consider reusing them. Attachment reuse works with sending images, audio clips, videos and files.

Usage:
>>> # Set the url for the hosted media
>>> media_url = "http://i.imgur.com/uAUm3VW.jpg"
>>> # Call the upload function. The response contains
>>> # an id that should be stored. This id is the reference
>>> # to send the same attachment in the future.
>>> response = fbbotw.upload_reusable_attachment(
        media_url=media_url,
        file_type="image" # Always specify the file type
    )
>>> # to get the attachment id, call the .json() function on
>>> # the response object and get it on the returned dict.
>>> attachment_id = response.json()['attachment_id']
>>> # Store the attachment id to use later (You can
>>> # use fbbotw.post_reusable_attachment to send it)
Parameters:
  • media_url (str) – Url of a hosted media.
  • file_type (str) – ‘image’/’audio’/’video’/’file’.
Returns:

Response object (Contains the attachment id to be used in fbbotw.post_reusable_attachment).

Facebook docs:

/send-api-reference#attachment_reuse