Facebook发布HTTP错误400:请求错误 [英] Facebook publish HTTP Error 400 : bad request

查看:164
本文介绍了Facebook发布HTTP错误400:请求错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,我正尝试通过python的urllib2库将分数发布到Facebook.

Hey I am trying to publish a score to Facebook through python's urllib2 library.

import urllib2,urllib

url = "https://graph.facebook.com/USER_ID/scores"
data = {}
data['score']=SCORE
data['access_token']='APP_ACCESS_TOKEN'
data_encode = urllib.urlencode(data)
request = urllib2.Request(url, data_encode)
response = urllib2.urlopen(request)
responseAsString = response.read()

我收到此错误:

   response = urllib2.urlopen(request)
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py", line 124, in urlopen
    return _opener.open(url, data, timeout)
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py", line 389, in open
    response = meth(req, response)
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py", line 502, in http_response
    'http', request, response, code, msg, hdrs)
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py", line 427, in error
    return self._call_chain(*args)
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py", line 361, in _call_chain
    result = func(*args)
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py", line 510, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 400: Bad Request

不确定这是否与Facebook的Open Graph或urllib2 API使用不当有关.

Not sure if this is relating to Facebook's Open Graph or improper urllib2 API use.

推荐答案

我运行了您的代码,并得到了相同的错误(正文中没有更多错误,本可以在评论中发布,但我猜还不能),所以我用Google搜索发布Facebook分数".

I ran your code and got the same error (there is no more error in the body, would have posted that in a comment but can't yet I guess) so I googled "publish facebook scores."

我相信您需要首先授予应用程序发布分数的权限,除非您已经这样做.参见 http://developers.facebook.com/blog/post/539/.

I believe you'll need to grant your app permission to publish scores first, unless you've done that already. See http://developers.facebook.com/blog/post/539/.

这篇关于Facebook发布HTTP错误400:请求错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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