facebook pythonsdk张贴到墙附件

2024-04-19 15:48:34 发布

您现在位置:Python中文网/ 问答频道 /正文

嗨 我正在使用pythonsdk(http://github.com/facebook/python-sdk.git)在谷歌appengine上。 我正在运行“newsfeed”示例。
在脸谱网.py我不得不导入urllib2
然后改变

file = urllib.urlopen("https://graph.facebook.com/" + path + "?" +
                          urllib.urlencode(args), post_data)  

^{pr2}$

现在基本的应用程序开始工作了。但是如果我改变了
facebook客户端.py

    try:  
        self.graph.put_wall_post(message)  
    except Exception, e:  
        self.response.out.write(e)  
        return  

    try:  
        attachment = {}  
        message = message         
        caption = 'test caption'  
        attachment['caption'] = caption  
        attachment['name'] = 'test name'  
        attachment['description'] = 'test description'  
        self.graph.put_wall_post(message, attachment=attachment)  
    except Exception, e:  
        self.response.out.write(e)  
        return  

我将得到错误(在http://localhost:8080):
HTTP错误400:错误请求
appengine开发服务器抱怨:
信息2010-10-24 17:20:44483开发_appserver.py:3275]“POST/POST HTTP/1.1”302- 警告2010-10-24 17:20:44570 urlphetch_存根。py:284]从urlphetch请求中删除了禁止的头:['Host']
信息2010-10-24 17:20:48167开发_appserver.py:3275]“获取/HTTP/1.1”200-
信息2010-10-24 17:20:48292开发_appserver.py:3275]“获取/静态/基本.cssHTTP/1.1“200-
警告2010-10-24 17:21:19343 urlphetch_存根。py:284]从urlphetch请求中删除了禁止的头:['Content-Length','Host']
信息2010-10-24 17:21:20634开发_appserver.py:3275]第200.1版后HTTP-


Tags: pytestself信息httpmessageattachmentfacebook
1条回答
网友
1楼 · 发布于 2024-04-19 15:48:34

通过使用“放置”对象而不是“粘贴到墙”来解决此问题:
有关如何使用curl进行post的示例,请参见http://developers.facebook.com/docs/reference/api/post

 self.graph.put_object("me", "feed", message=message,  
                             link="http://leona-nachhilfe.appspot.com",  
                             picture="http://leona-nachhilfe.appspot.com/static/images/logo.png",    
                             name = "LeONa-Quiz",    
                             description = "Orges erreichte 45.Punkte",
                             actions = {'name': 'Zu den Quiz-Aufgaben', 'link': 'http://leona-nachhilfe.appspot.com'},
                             privacy = {'value': 'ALL_FRIENDS'}
                             )

相关问题 更多 >