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

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

问题描述



我无法使用这个API [朋友]:


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


因为这个API只返回任何使用过该应用的请求的朋友。



所以我发现这个API [friendlist]:


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


跟随这个答案,我收到了朋友列表。



但是,当尝试获取friendlist的成员时,我会收到空​​列表:

 新请求(
会话,
/ 2692926356774 / members,
null,
HttpMethod.GET,
new Request.Callback()
{
public void onCompleted(Response response)
{
/ *处理结果* /
Log.e(LOG_TAG,Members:+ response.toString());
}
}
).executeAsync();

2692926356774 是我的认识列表ID ,我尝试了其他一些id的结果相同。

解决方案

在v2中。 0的Graph API,调用 / me / friends 返回还有使用该应用的人的朋友。



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



/ me / friendlists 端点和 user_friendlists 权限不是你后。此端点不返回用户的朋友 - 它允许您访问一个人为组织他们的朋友所做的列表。它不返回每个这些列表中的朋友。这个API和权限对于让人们有机会发布回Facebook时,可以渲染自定义隐私选择器。



如果您想访问非-app-使用的朋友,有两个选择:


  1. 如果您想让自己的人员将自己的朋友标记为他们的朋友 ,他们会在使用您的App发布到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天全站免登陆