Python facebook sdk图形api访问错误
我正在使用Facebook页面获取用户的帖子 在facebook Graph api explorer中,请求进行得很顺利:Python facebook sdk图形api访问错误,python,facebook-graph-api,facebook-access-token,Python,Facebook Graph Api,Facebook Access Token,我正在使用Facebook页面获取用户的帖子 在facebook Graph api explorer中,请求进行得很顺利: Get .../coldplay/feed?limit=2 在我的程序中,请求: In [27]: graph = facebook.GraphAPI("...") In [28]: posts = graph.get_object('coldplay/feed?limit=2') 报告错误: GraphAPIError
Get .../coldplay/feed?limit=2
在我的程序中,请求:
In [27]: graph = facebook.GraphAPI("...")
In [28]: posts = graph.get_object('coldplay/feed?limit=2')
报告错误:
GraphAPIError Traceback (most recent call last)
/home/ubuntu/<ipython console> in <module>()
/usr/local/lib/python2.7/dist-packages/facebook.pyc in get_object(self, id, **args)
97 def get_object(self, id, **args):
98 """Fetchs the given object from the graph."""
---> 99 return self.request(id, args)
100
101 def get_objects(self, ids, **args):
/usr/local/lib/python2.7/dist-packages/facebook.pyc in request(self, path, args, post_args)
296 except urllib2.HTTPError, e:
297 response = _parse_json(e.read())
--> 298 raise GraphAPIError(response)
299 except TypeError:
300 # Timeout support for Python <2.6
所以我想知道如何发出请求:“…/feed?limit=2”对Python facebook sdk很有效?谢谢。您应该提供
limit
作为参数,而不是对象的一部分
get_object
的定义是def get_object(self、id、**args)
,这意味着您需要提供关键字args
在您的例子中:graph.get\u对象('coldplay/feed',limit=2)
In [45]: graph = facebook.GraphAPI("...")
In [46]: posts = graph.get_object('coldplay/feed')
In [47]: len(posts)
Out[47]: 2