使用Python将图片发布到Facebook

Adh*_*ham 6 python curl http urllib urllib2

如何使用Python将图像发布到Facebook?

kai*_*oku 5

您可以使用facebook提供的Python SDK通过oauth密钥上传照片。
获得oauth密钥后,可以使用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()
Run Code Online (Sandbox Code Playgroud)