首页 文章

使用Facebook Graph API获取所有用户朋友 - Android [复制]

提问于
浏览
48

这个问题在这里已有答案:

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

我无法使用此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

Followed this answer,我收到了好友列表 .

但是当我试图获得friendlist的成员时,我会得到空列表:

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 是我的 Acquaintances list id ,我尝试了其他一些具有相同结果的id .

1 回答

  • 81

    在Graph API的v2.0中,调用 /me/friends 会返回同时使用该应用程序的人的朋友 .

    此外,在v2.0中,您必须从每个用户请求 user_friends 权限 . 每次登录时都不再包含 user_friends . 每个用户必须授予 user_friends 权限才能显示在 /me/friends 的响应中 . 有关更多详细信息,请参阅the Facebook upgrade guide,或查看以下摘要 .

    /me/friendlists endpoints 和 user_friendlists 权限不是您所追求的 . 此 endpoints 不会返回用户朋友 - 它允许您访问一个人为组织朋友而制作的列表 . 它不会返回每个列表中的朋友 . 此API和权限对于允许您在向人们提供发布回Facebook的机会时呈现自定义隐私选择器非常有用 .

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

    • If you want to let your people tag their friends 在他们使用您的应用程序发布到Facebook的故事中,您可以使用 /me/taggable_friends API . Use of this endpoint requires review by Facebook并且只应用于渲染朋友列表以便让用户在帖子中标记它们的情况 .

    • If your App is a Game AND your Game supports Facebook Canvas ,您可以使用 /me/invitable_friends endpoints 来渲染a custom invite dialog,然后将此API返回的标记传递给the standard Requests Dialog.

    在其他情况下,应用程序无法再检索用户朋友的完整列表(仅限那些使用 user_friends 权限明确授权您的应用的朋友) .

    对于希望允许人们邀请朋友使用应用的应用,您仍然可以使用Send Dialog on Web或新的Message Dialog on iOSAndroid .

相关问题