使用 Facebook Graph API 获取所有用户好友 - Android [英] Get ALL User Friends Using Facebook Graph API - Android

查看:53
本文介绍了使用 Facebook Graph API 获取所有用户好友 - Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取登录我的应用程序的用户的所有朋友.

我不能使用这个 API [朋友]:

<块引用>

https://developers.facebook.com/docs/graph-api/reference/v2.0/user/friends

因为此 API 仅返回使用该应用程序发出请求的所有朋友.

于是我找到了这个 API [好友列表]:

<块引用>

https://developers.facebook.com/docs/graph-api/reference/v2.0/friendlist

按照这个答案,我得到了好友列表.

但是我在尝试获取好友列表成员时得到了空列表:

新请求(会议,"/2692926356774/成员",空值,HttpMethod.GET,新的 Request.Callback(){public void onCompleted(响应响应){/* 处理结果 */Log.e(LOG_TAG,"成员:" + response.toString());}}).executeAsync();

2692926356774 是我的熟人列表 id,我尝试了几个其他 id 的结果相同.

解决方案

在 Graph API v2.0 中,调用 /me/friends 会返回此人的好友,他们也使用该应用.

此外,在 v2.0 中,您必须向每个用户请求 user_friends 权限.user_friends 不再默认包含在每次登录中.每个用户都必须授予 user_friends 权限才能出现在对 /me/friends 的响应中.请参阅Facebook 升级指南了解更多详细信息,或查看下面的摘要.

/me/friendlists 端点和 user_friendlists 权限不是您想要的.这个端点不会返回用户的朋友——它允许你访问一个人为组织他们的朋友而制作的列表.它不会返回每个列表中的朋友.此 API 和权限非常有用,可让您在让人们有机会发回 Facebook 时呈现自定义隐私选择器.

如果您想访问不使用应用程序的朋友列表,有两种选择:

  1. 如果你想让你的人标记他们的朋友在他们使用您的应用发布到 Facebook 的快拍中,您可以使用 /me/taggable_friends API.使用此端点需要 Facebook 审核,并且只能用于呈现朋友列表以便让用户在帖子中标记他们的情况.

  2. 如果您的应用是游戏并且是您的游戏支持 Facebook Canvas,您可以使用 /me/invitable_friends 端点来渲染 自定义邀请对话框,然后将此 API 返回的令牌传递给 标准的请求对话框.

在其他情况下,应用不再能够检索用户好友的完整列表(只有那些使用 user_friends 权限专门授权您的应用的好友).

对于希望允许人们邀请朋友使用应用程序的应用程序,您仍然可以使用发送对话框Web 或新的 iOS 上的消息对话框Android.

I'm trying to get all friends, of a user that logged into my application.

I can't use this API [friends]:

https://developers.facebook.com/docs/graph-api/reference/v2.0/user/friends

Because this API only returns any friends who have used the app making the request.

So I found this API [friendlist]:

https://developers.facebook.com/docs/graph-api/reference/v2.0/friendlist

Followed this answer, I got the friendlist list.

But I'm getting empty list when trying to get friendlist's members:

new Request(
            session,
            "/2692926356774/members",
            null,
            HttpMethod.GET,
            new Request.Callback()
            {
                public void onCompleted(Response response)
                {
                    /* handle the result */
                    Log.e(LOG_TAG,"Members: " + response.toString());
                }
            }
    ).executeAsync();

2692926356774 is my Acquaintances list id, I tried few other id's with the same result.

解决方案

In v2.0 of the Graph API, calling /me/friends returns the person's friends who also use the app.

In addition, in v2.0, you must request the user_friends permission from each user. user_friends is no longer included by default in every login. Each user must grant the user_friends permission in order to appear in the response to /me/friends. See the Facebook upgrade guide for more detailed information, or review the summary below.

The /me/friendlists endpoint and user_friendlists permission are not what you're after. This endpoint does not return the users friends - its lets you access the lists a person has made to organize their friends. It does not return the friends in each of these lists. This API and permission is useful to allow you to render a custom privacy selector when giving people the opportunity to publish back to Facebook.

If you want to access a list of non-app-using friends, there are two options:

  1. If you want to let your people tag their friends in stories that they publish to Facebook using your App, you can use the /me/taggable_friends API. Use of this endpoint requires review by Facebook and should only be used for the case where you're rendering a list of friends in order to let the user tag them in a post.

  2. If your App is a Game AND your Game supports Facebook Canvas, you can use the /me/invitable_friends endpoint in order to render a custom invite dialog, then pass the tokens returned by this API to the standard Requests Dialog.

In other cases, apps are no longer able to retrieve the full list of a user's friends (only those friends who have specifically authorized your app using the user_friends permission).

For apps wanting allow people to invite friends to use an app, you can still use the Send Dialog on Web or the new Message Dialog on iOS and Android.

这篇关于使用 Facebook Graph API 获取所有用户好友 - Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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