Skip to content

Replace the image of a facebook post #486

@Rabelaiss

Description

@Rabelaiss

Version of the SDK being used

By running

import facebook
print(facebook.__version__)

the result is 3.1.0

Expected Behavior

The image of an existing facebook post gets replaced by the one indicated in the code.

Actual Behavior

Nothing happens and no errors in the console.

Steps to Reproduce

There is a post on my facebook page which has some text and an image, and I would like to replace the image with another one saved on my computer. Using the graph API I'm able to easily update/edit the text of the post in this way

import facebook
page_token = '...'
fb = facebook.GraphAPI(access_token = page_token, version="2.12")
page_id = '...'
post_id = '...'
fb.put_object(parent_object = page_id + '_' + post_id,
              connection_name = '',
              message = 'new text')

I tried to update/edit the image of the post with the commands

fb.put_object(parent_object = page_id + '_' + post_id,
              connection_name = '',
              message = 'new text',
              source = open('out.png', 'rb'))

and

fb.put_object(parent_object = page_id + '_' + post_id,
              connection_name = '',
              message = 'new text',
              object_attachment = open('out.png', 'rb'))

but none of them works, even though there are no errors during the execution of the code.
What is wrong?
In the documentation there are only two parameters for put_object even though they are more for sure, so I don't understand if I'm doing something wrong or if there is something wrong with the function itself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions