开发者

How can I post photo to facebook with python sdk

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 =开发者_如何学Python 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("/")


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜