我创建了Facebook个人资料并创建了页面https://www.facebook.com/pages/Animated-GIF/872749676114274?fref=nf。 1.我安装了facebook python sdk。 2.为我的Facebook个人资料创建应用程序并获取访问令牌。 3.现在我可以使用此代码在我的Facebook个人资料中提交帖子
Notification
一切都好。但我如何代表动画gif向https://www.facebook.com/pages/Animated-GIF/872749676114274页面提交帖子给Facebook? 谢谢
答案 0 :(得分:1)
制作专辑
graph = facebook.GraphAPI(access_token)
path = "1640987309510499/albums"
post_args = {'access_token':access_token,'name':"Animated GIFs collection ", 'message':"Animated GIFs collection "}
post_data = urllib.urlencode(post_args)
file = urllib2.urlopen("https://graph.facebook.com/" + path + "?" , post_data)
response = file.read()
al_id = response.replace("{\"id\":\"","").replace("\"}","")
嵌入帖子
photo = open("/var/www/gif/crons/fgif.gif", 'rb')
new_photo = graph.post('%s/photos' % album_id_, params={'message':title, 'source': photo})