Facebook Graph API v2.0+ -/me/friends 返回空,或者只有也使用我的应用程序的朋友 [英] Facebook Graph API v2.0+ - /me/friends returns empty, or only friends who also use my application

查看:19
本文介绍了Facebook Graph API v2.0+ -/me/friends 返回空,或者只有也使用我的应用程序的朋友的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Graph API v2.0 获取我的朋友姓名和 ID,但数据返回空:

{数据": []}

当我使用 v1.0 时,以下请求一切正常:

FBRequest*friendsRequest = [FBRequest requestForMyFriends];[friendsRequest startWithCompletionHandler: ^(FBRequestConnection *connection,NSDictionary* 结果,NSError *错误){NSArray*friends = [result objectForKey:@"data"];NSLog(@"找到: %i 个朋友",friends.count);for (NSDictionary* 朋友中的朋友) {NSLog(@"我有一个朋友叫%@,id是%@",friend.name,friend.id);}}];

但现在我交不到朋友了!

解决方案

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

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

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

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

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

在其他情况下,应用不再能够检索用户好友的完整列表(只有那些使用 user_friends 权限专门授权您的应用的好友).这已被 Facebook 确认为设计使然".

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

更新:Facebook 在此处发布了有关这些更改的常见问题解答:https://developers.facebook.com/docs/apps/faq 解释了开发人员可以使用的所有选项,以便邀请朋友等.

I am trying to get my friend name and ids with Graph API v2.0, but data returns empty:

{
  "data": [
  ]
}

When I was using v1.0, everything was OK with the following request:

FBRequest* friendsRequest = [FBRequest requestForMyFriends];
[friendsRequest startWithCompletionHandler: ^(FBRequestConnection *connection,
                                              NSDictionary* result,
                                              NSError *error) {
    NSArray* friends = [result objectForKey:@"data"];
    NSLog(@"Found: %i friends", friends.count);
    for (NSDictionary<FBGraphUser>* friend in friends) {
        NSLog(@"I have a friend named %@ with id %@", friend.name, friend.id);
    }
}];

But now I cannot get friends!

解决方案

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.

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). This has been confirmed by Facebook as 'by design'.

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.

UPDATE: Facebook have published an FAQ on these changes here: https://developers.facebook.com/docs/apps/faq which explain all the options available to developers in order to invite friends etc.

这篇关于Facebook Graph API v2.0+ -/me/friends 返回空,或者只有也使用我的应用程序的朋友的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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