facebook使用python获取朋友的生日

时间:2013-11-04 03:13:33

标签: python facebook facebook-graph-api

我只是想在Facebook上使用它的python api

来结交朋友的生日

我在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
有人帮忙吗?

3 个答案:

答案 0 :(得分:2)

实际上,这有效......

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

离奇

答案 1 :(得分:0)

答案 2 :(得分:0)

我调整了一点,这部分有用。

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

然而,它只返回一些生日(我只有600多位朋友中的3位)。

相关问题