How can I post photo to facebook with python sdk

*爱你&永不变心* 提交于 2019-12-08 07:37:27

问题


I am using the python SDK on google app engine, and I'm runnig the "newsfeed" example. I tried to change the example code in order to upload local image file to facebook.

And follow is my change, but i don't know how to finish it. I'm wondering that how to change facebookclient.py or facebook.py to upload image.

Thanks

home.html

<form action="/post" enctype="multipart/form-data" method="post">
    <div class="textbox"><textarea name="message"></textarea></div>
    <div><input name="image" type="file"/></div>
    <div class="buttons"><input type="submit" value="Share"/></div>
</form>

facebookclient.py

class PostHandler(BaseHandler):
    def post(self):
        message = self.request.get("message")
        image = self.request.get("image")
        if not self.current_user or not message:
            self.redirect("/")
            return
        try:
            # self.graph.put_wall_post(message)
        except:
            pass
        self.redirect("/")

回答1:


Using the facebook API is a bit more complicated: a single request won't do the trick, there's authentication involved.

Fortunately, the documentation is quite good. See here, and look under the Publishing section for your specific needs.



来源:https://stackoverflow.com/questions/5141834/how-can-i-post-photo-to-facebook-with-python-sdk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!