GAE和Facebook Connect:如何获取用户的年龄和性别? [英] GAE and Facebook Connect: How to get age and gender of user?

查看:593
本文介绍了GAE和Facebook Connect:如何获取用户的年龄和性别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在与Google App Engine和Facebook Connect合作。

I'm working with Google App Engine and Facebook Connect.

我已经在 https://github.com/facebook/python-sdk/tree/master/examples/appengine ,它有一些例子用于基本用户登录和获取他们的名字和朋友。

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?

推荐答案

你不需要任何Gender属性的权限的用户和年龄,您可以通过减去当前日期的用户的出生日期来计算。

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.

对于出生日期,您需要 user_birthday 扩展许可

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

查看此处的示例github https://github.com/facebook/python- sdk / blob / master / examples / appengine / example.py

Check out the example here on github https://github.com/facebook/python-sdk/blob/master/examples/appengine/example.py

我不知道python自己,但是,如果你使用python sdk,那么你可以请求用户信息(从上面的示例推断)

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.

这篇关于GAE和Facebook Connect:如何获取用户的年龄和性别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆