Python Forum

Full Version: How to add an image to an existing facebook post using python graph API?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm using facebook graph API to update/edit the text of a specific post on my page

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')
now I'm trying to add a local image (stored in the same folder of the python script) to this post but I don't understand how to properly do it (notice that I don't have to create a new post and attach a photo (for which we simply use put_photo function) but I have to attach a photo to an existing post).
What I tried so far

    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 (there are no errors when running the code, but the image is not added to the post).
Hints?

p.s. these are the permission of my app

    pages_show_list
    pages_read_engagement
    pages_read_user_content
    pages_manage_posts
    pages_manage_engagement