如何使用python sdk将照片发布给Facebook? [英] How can I post photo to facebook with python sdk

查看:264
本文介绍了如何使用python sdk将照片发布给Facebook?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Google应用引擎上使用 python SDK ,我跑了新闻源的例子。我试图更改示例代码,以便将本地图像文件上传到Facebook。

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.

跟随是我的变化,但我不知道如何完成它。我想知道如何更改facebookclient.py或facebook.py上传图片。

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.

谢谢

home.html

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

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("/")


推荐答案

使用Facebook API有点复杂:一个请求不会做的伎俩,有认证涉及。

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.

这篇关于如何使用python sdk将照片发布给Facebook?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆