我试图发布到页面提要与多个图像。我遵循的是医生的 Facebook图形API和医生的 facebook-sdk for python。只有消息被发布,没有图像。
token = "my_token"
graph = facebook.GraphAPI(access_token=token, version="3.0")
photo_id = graph.put_photo(image=open('favicon.png', 'rb'), published=False)
print('PHOTO ID ', photo_id.get('id', ''))
post = graph.put_object(parent_object="page_id", connection_name="feed", message="Message with images upload!", attachments=[{'media_fbid': photo_id.get('id', '')}])
print('POST ID', post.get('id', ''))返回图像和post ID时不会出现错误。但是,图像并没有随消息一起发布。我在使用附件参数,也许是另一种。有什么想法吗?
发布于 2018-09-29 03:28:25
我找到了回答
您应该使用json.dumps和attached_media作为参数:
import json
graph.put_object(parent_object="page_id", connection_name="feed", message="Message with multiple files!", attached_media=json.dumps([{'media_fbid': str(photo_id.get('id', ''))}]))https://stackoverflow.com/questions/52564590
复制相似问题