在 Facebook 应用程序中获取朋友的性别

发布于 2024-10-07 13:43:47 字数 595 浏览 2 评论 0原文

在开发 Facebook 应用程序时,我通过以下方式获取了用户的好友列表

$friends = $facebook->api('/me/friends');

但我只知道朋友的名字和 Facebook Id:http://developers。 facebook.com/docs/reference/api/FriendList

有没有办法获取朋友的性别?

一种方法是根据用户的 facebook Id(我使用朋友列表获得)获取用户的性别(因为它是公开的)

是否真的可以执行上述操作。

如果没有还有其他办法吗?

供参考: http://developers.facebook.com/docs/reference/api/user< /a>

While developing a Facebook application I got the friendlist of a user by

$friends = $facebook->api('/me/friends');

But I only got to know the name and Facebook Ids of the friends : http://developers.facebook.com/docs/reference/api/FriendList

Is there any way to get the gender of a friend?

One way to do so is to get the user's gender (since it is publicly available) given the user's facebook Id (which I have got using the friend list)

Is it really possible to do the above thing.

If not is there any other way?

for reference : http://developers.facebook.com/docs/reference/api/user

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

花心好男孩 2024-10-14 13:43:47

使用 Graph API 的快速方法

$facebook->api('me/friends?fields=id,name,gender,installed&access_token=[ACCESS_TOKEN]");

A quick way with Graph API

$facebook->api('me/friends?fields=id,name,gender,installed&access_token=[ACCESS_TOKEN]");
高速公鹿 2024-10-14 13:43:47

http://developers.facebook.com/docs/reference/api/FriendList = 一个人的恶魔列表(复数) - 例如:Limited Profile

你想要做的是从 graph.facebook.com/me/firends 获取 ID,然后为性别做一个 graph.facebook.com/ID。但当然,如果你需要为他们所有的朋友提供它,最终会产生很多请求。

对于这些情况,您可以使用 FQL 查询: http://developers.facebook.com/docs/reference /fql/

您可以从他们的文档中采用以下查询:

SELECT uid, name, pic_square FROM user WHERE uid = me() OR uid IN (SELECT uid2 FROM friend WHERE uid1 = me())

这里是当前用户好友的姓名和性别:

SELECT uid, name, sex FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())

http://developers.facebook.com/docs/reference/api/FriendList = a persons fiend lists (plural) - eg: Limited Profile

What you want to do is get the ID from graph.facebook.com/me/firends and then do a graph.facebook.com/ID for the gender. But of course that ends up being a lot of requests if you need it for all of their friends.

For those cases you can use FQL query: http://developers.facebook.com/docs/reference/fql/

You can adopt following query from their documentation:

SELECT uid, name, pic_square FROM user WHERE uid = me() OR uid IN (SELECT uid2 FROM friend WHERE uid1 = me())

Here name and gender of the current users friends:

SELECT uid, name, sex FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文