Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Post picture to Facebook using Python

How can I post an image to Facebook using Python?

like image 270
Adham Avatar asked Feb 25 '11 14:02

Adham


2 Answers

You can use the facebook provided Python SDK to upload photos using an oauth key.
Once you get the oauth key, you can upload a picture with GraphAPI.put_object():

graph = facebook.GraphAPI(oauth_access_token)
photo = open("picture.jpg", "rb")
graph.put_object("me", "photos", message="You can put a caption here", source=photo.read())
photo.close()
like image 59
kaizoku Avatar answered Oct 02 '22 23:10

kaizoku


Unfortunately, the Python SDK is discontinued now. Will not work. Need to use Javascript / PHP / iOS / Android APIs

like image 43
Sriram V Iyer Avatar answered Oct 02 '22 23:10

Sriram V Iyer