Facebook使用Python获取朋友的生日



我只是想用它的python api在Facebook上得到我朋友的生日

我在 https://developers.facebook.com/tools/explorer/中尝试了"me/friends?fields=birthday"的查询,效果很好,但是在我的python代码中,它说"GraphAPIError:必须使用活动访问令牌来查询有关当前用户的信息。

我在这里发布了我的代码:

import facebook
token = 'a token' # token omitted here, this is the same token when I use in https://developers.facebook.com/tools/explorer/ 
graph = facebook.GraphAPI(token)
fb = graph.request("me/friends?fields=birthday")
# while graph.request("me/friends") works well

print fb

有人帮忙?

实际上,这有效...

args = {'fields' : 'birthday,name' }
friends = graph.get_object("me/friends",**args)

古怪

我稍微

调整了一下,这部分有效。

from facepy import GraphAPI
graph=GraphAPI('AccessToken')
friends=[]
friends= graph.get("me/friends?fields=birthday") 
print friends

但是,它只返回一些生日(只返回我拥有的 3+ 朋友中的 600 个)。

您应该在那里提供 ID。有一个同样的问题。寻找:(OAuthException - #2500)必须使用活动访问令牌来查询有关当前用户的信息

最新更新