Question

I'm making a page that displays details of an event, and details of any user that has registered an interest in coming to that event. I am using Facebook's Python-SDK (https://github.com/facebook/python-sdk) and I have had no problem getting the access token of the currently logged-in user. However, when the user visits this page of event details, the intention is that they can see names and profile pics of the users involved in this event. I use this code to populate this list of users:

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)

The graph has already been defined at this point using:

graph = facebook.GraphAPI(self.current_user.access_token)

Here is the error I get:

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

The logging lines show me that the request took in a valid Facebook ID and access_token, so I don't understand what is going wrong here. Is it not possible to get the picture and username of other Facebook users apart from the one currently logged in?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top