我想知道用户有多少朋友。这是我尝试过的,但它不起作用:
>>> 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
}
}
答案 0 :(得分:2)
这是因为您的应用程序未请求(或没有用户授权)访问该用户的朋友连接。我可以在GraphAPI Explorer中查看该用户的基本详细信息,但如果我尝试查看“朋友”连接,则会将"Unsupported operation"
作为回复消息。
答案 1 :(得分:0)
我建议你的访问令牌是错误的。 尝试使用您的浏览器中插入访问令牌的此URL https://graph.facebook.com/puja41/friends?access_token=YOURTOKENHERE