0

我想知道一个用户有多少朋友。这是我尝试过的,但它不起作用:

>>> import facebook
>>> graph = facebook.GraphAPI("CAAEr.....XCODEe6bMZD")
>>> profile = graph.get_object('puja41')
>>> friends = graph.get_connections("puja41", "friends")

Traceback (most recent call last):
  File "<pyshell#54>", line 1, in <module>
    friends = graph.get_connections("puja41", "friends")
  File "C:/Documents and Settings/visolank/Desktop/Python/programs\facebook.py", line 112, in get_connections
    return self.request(id + "/" + connection_name, args)
  File "C:/Documents and Settings/visolank/Desktop/Python/programs\facebook.py", line 298, in request
    raise GraphAPIError(response)
GraphAPIError: Unsupported operation

当我尝试 JonasR 的建议时,我得到了:

{
   "error": {
      "message": "Unsupported operation",
      "type": "FacebookApiException",
      "code": 100
   }
}
4

2 回答 2

2

这是因为您的应用程序没有请求(或没有用户授予)访问该用户的朋友连接的权限。我可以在GraphAPI Explorer中查看该用户的基本详细信息,但如果我尝试查看“朋友”连接,我会收到"Unsupported operation"一条响应消息。

于 2013-07-09T15:31:05.890 回答
0

我建议您的访问令牌是错误的。尝试在浏览器中插入访问令牌的 URL https://graph.facebook.com/puja41/friends?access_token=YOURTOKENHERE

于 2013-07-09T15:12:37.987 回答