GAE and Facebook Connect: How to get age and gender of user?
I'm working with Google App Engine and Facebook Connect.
I have found Facebook Python SDK at https://github.com/facebook/python-sdk/tree/master/examples/appengine and it has some examples for basic user login and getting their names and开发者_开发知识库 friends.
How can I get the user's other information? I would like to have their age and gender for my app to work properly. I know it requires additional permissions to get that information but how do I do that?
You dont need any permission for Gender property of the user and for the Age you can calculate by Subtracting the User's Date of birth by current Date.
For Date of Birth you need user_birthday
Extended Permission
If you want to know how to request permissions specify them in scope
query parameter like this
https://graph.facebook.com/oauth/authorize?
client_id=YOUR_APP_ID&redirect_uri=YOUR_URL&scope=user_birthday
Check out the example here on github https://github.com/facebook/python-sdk/blob/master/examples/appengine/example.py
I dont know python myself but, If you are using the python sdk then you can request user information like this (inferred from the example above)
profile = graph.get_object("me")
gender = profile["gender"]
dateofbirth = profile["birthday"]
now you can get age by subtracting user date from current date.
精彩评论