0

I create facebook profile and create page https://www.facebook.com/pages/Animated-GIF/872749676114274?fref=nf . 1. I was install facebook python sdk. 2. Create application and get access token for my facebook profile. 3. Now I can submit post in my facebook profile with use this 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. But how I can submit post to facebook on behalf of animated gif to https://www.facebook.com/pages/Animated-GIF/872749676114274 page? Thank you

Vahagn
  • 105
  • 1
  • 12
  • 1
    Facebook doesn't support animated GIF's. To post a picture to facebook you will need a post request, take a look here: http://stackoverflow.com/questions/2718610/upload-photo-to-album-with-facebooks-graph-api – Ayy Aug 07 '15 at 21:37

1 Answers1

1

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})
Vahagn
  • 105
  • 1
  • 12