Facebook Python SDK - 在事件创建中上传图像

时间:2012-07-17 01:41:07

标签: python facebook api events

在图表api上创建活动时如何上传图片? 例如:

user.facebook.put_object("me", "events", name="test", start_time=start_date, end_time=end_date, picture=image)

我试过了:

 image = 'C:\\Path\\to\\image.jpg' #and
 image = open('C:\\Path\\to\\image.jpg', 'a') #and
 image = open('C:\\Path\\to\\image.jpg', 'a').read() #and

没有工作。

1 个答案:

答案 0 :(得分:0)

来自github上的文档:https://github.com/pythonforfacebook/facebook-sdk/

graph = facebook.GraphAPI(oauth_access_token)
tags = json.dumps([{'x':50, 'y':50, tag_uid:12345}, {'x':10, 'y':60, tag_text:'a turtle'}])
graph.put_photo(open('img.jpg'), 'Look at this cool photo!', album_id_or_None, tags=tags)