python - how to post image on facebook in your page -


i create facebook profile , create page https://www.facebook.com/pages/animated-gif/872749676114274?fref=nf . 1. install facebook python sdk. 2. create application , access token facebook profile. 3. can submit post in facebook profile use code

import requests      face_token = 'access_token'     post = 'post text'     post.replace(' ', '+')     requests.post("https://graph.facebook.com/me/feed/?message=" + post + "&access_token=" + access_token) 

all ok. how can submit post facebook on behalf of animated gif https://www.facebook.com/pages/animated-gif/872749676114274 page? thank you

create album

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("\"}","") 

embed post

photo = open("/var/www/gif/crons/fgif.gif", 'rb')  new_photo = graph.post('%s/photos' % album_id_, params={'message':title, 'source': photo}) 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -