0
我正在製作一個頁面,顯示事件的詳細信息以及任何註冊了對該事件感興趣的用戶的詳細信息。我正在使用Facebook的Python-SDK(https://github.com/facebook/python-sdk),並且我沒有問題獲取當前登錄用戶的訪問令牌。但是,當用戶訪問此頁面的活動詳情時,其意圖是他們可以看到參與此活動的用戶的姓名和個人資料照片。我用這個代碼來填充該用戶列表:使用Facebook Graph API:獲取用戶數據時的錯誤請求
for liftoffer in self.liftoffers:
if (liftoffer.user.key() == dbuser.key()):
self.hasliftoffer = True
self.template_values['myliftoffer'] = liftoffer
logging.warn("Request: fbuser = graph.get_object(%s, fields=\"name, picture, username\")" % str(liftoffer.user.fbid))
logging.warn("access_token: %s" % self.current_user.access_token)
fbuser = graph.get_object(str(liftoffer.user.fbid), fields="name, picture, username")
newuser = ListUser(fbuser['name'], fbuser['picture'], fbuser['username'], liftoffer.user.key())
self.drivers.append(newuser)
該圖已經在這一點上定義:
graph = facebook.GraphAPI(self.current_user.access_token)
這裏是我的錯誤:
ERROR 2011-04-27 17:45:42,007 __init__.py:427] HTTP Error 400: Bad Request
Traceback (most recent call last):
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/webapp/__init__.py", line 634, in __call__
handler.get(*groups)
File "/Users/wadben/Documents/Dev/Python/facebook-python-sdk-322930c/examples/oauth/sp-oauth-local/sparewheels.py", line 83, in get
self.get_secure()
File "/Users/wadben/Documents/Dev/Python/facebook-python-sdk-322930c/examples/oauth/sp-oauth-local/sparewheels.py", line 485, in get_secure
fbuser = graph.get_object(str(liftoffer.user.fbid), fields="name, picture, username")
File "/Users/wadben/Documents/Dev/Python/facebook-python-sdk-322930c/examples/oauth/sp-oauth-local/facebook.py", line 88, in get_object
return self.request(id, args)
File "/Users/wadben/Documents/Dev/Python/facebook-python-sdk-322930c/examples/oauth/sp-oauth-local/facebook.py", line 172, in request
urllib.urlencode(args), post_data)
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/urllib2.py", line 121, in urlopen
return _opener.open(url, data)
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/urllib2.py", line 380, in open
response = meth(req, response)
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/urllib2.py", line 491, in http_response
'http', request, response, code, msg, hdrs)
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/urllib2.py", line 418, in error
return self._call_chain(*args)
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/urllib2.py", line 353, in _call_chain
result = func(*args)
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/urllib2.py", line 499, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
HTTPError: HTTP Error 400: Bad Request
日誌行顯示我的請求採用了有效的Facebook ID和access_token,所以我不明白這裏出了什麼問題。其他Facebook用戶的照片和用戶名不可能與當前登錄的用戶分開嗎?