GAE and Facebook Connect: How to get age and gender of user?

☆樱花仙子☆ 提交于 2020-03-21 03:44:05

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/4777518/gae-and-facebook-connect-how-to-get-age-and-gender-of-user

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!