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, I tried
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. 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
EDIT: I tried with the function put_photo
but it creates a new post adding the image to it, while I need to add an image to an already existing post
2
Answers
https://developers.facebook.com/docs/graph-api/reference/page/photos/
https://developers.facebook.com/docs/graph-api/reference/photo/
The Documentation states you can not perform updates.
I made a complete selenium script in python which can handle the same task :
All you need to do is to change the variables given above
Note:- It is working dated 9 Dec, 2020