Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
facebook python sdk贴到墙上的附件_Python_Facebook_Attachment - Fatal编程技术网

facebook python sdk贴到墙上的附件

facebook python sdk贴到墙上的附件,python,facebook,attachment,Python,Facebook,Attachment,嗨 我正在使用python sdk(http://github.com/facebook/python-sdk.git)在谷歌appengine上。 我正在运行“新闻提要”示例。 在facebook.py中,我必须导入urllib2 然后改变 file = urllib.urlopen("https://graph.facebook.com/" + path + "?" + urllib.urlencode(args), post_data)

嗨 我正在使用python sdk(http://github.com/facebook/python-sdk.git)在谷歌appengine上。 我正在运行“新闻提要”示例。
在facebook.py中,我必须导入urllib2
然后改变

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

现在,基本的应用程序工作了。但是如果我改变
在facebookclient.py中

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

我将(在上)获取错误:
HTTP错误400:请求错误
appengine开发服务器抱怨:
信息2010-10-2417:20:44483 dev_appserver.py:3275]“POST/POST HTTP/1.1”302- 警告2010-10-24 17:20:44570 urlfetch_stub.py:284]从urlfetch请求中删除禁止的头:[“主机”]
信息2010-10-2417:20:48167 dev_appserver.py:3275]“GET/HTTP/1.1”200-
信息2010-10-24 17:20:48292 dev_appserver.py:3275]“GET/static/base.css HTTP/1.1”200-
警告2010-10-24 17:21:19343 urlfetch_stub.py:284]从urlfetch请求中删除禁止的头:[“内容长度”,“主机”]

信息2010-10-24 17:21:20634 dev_appserver.py:3275]“POST/POST HTTP/1.1”200-

通过使用put_对象而不是POST_to_wall解决了这个问题:
有关如何使用curl发布的示例,请参见

 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'}
                             )
    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  
 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'}
                             )