2

I just wanted to get my friends' birthday on facebook using its python api

I tried the query in https://developers.facebook.com/tools/explorer/ with "me/friends?fields=birthday", which works fine, but in my python code it says "GraphAPIError: An active access token must be used to query information about the current user."

I posted my code here:

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

someone helps?

Coderzelf
  • 752
  • 3
  • 10
  • 26
  • You need to get a valid token, not your own randomly generated string. [This thread](http://stackoverflow.com/questions/14611240/how-to-connect-to-facebook-graph-api-from-python-using-requests-if-i-do-not-need) suggests how. – Domi Nov 04 '13 at 03:18
  • Not a random token, I just omit it here – Coderzelf Nov 04 '13 at 03:26

3 Answers3

4

Actually, this works...

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

quirkily

Coderzelf
  • 752
  • 3
  • 10
  • 26
1

I tweaked it a little and this works partially.

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

However, it returns only some birthdays(returned just 3 of the 600+ friends I have).

siva
  • 331
  • 3
  • 5
0

You should supply ID there.There a same question. looking for: (OAuthException - #2500) An active access token must be used to query information about the current user

Community
  • 1
  • 1
Alan
  • 1,691
  • 1
  • 16
  • 13