Facebook Graph Api v2.0 + - / me / friends返回空白,还是仅使用我的应用程序的朋友 [英] Facebook Graph Api v2.0+ - /me/friends returns empty, or only friends who also use my app

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

问题描述

我试图用图表api v2.0,
获取我的朋友姓名和ids,但是数据返回空:

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

{
  "data": [
  ]
}

当我使用v1.0时,一切都可以满足以下要求:

when I was using v1.0, everything was ok with 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!

推荐答案

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

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

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

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. 如果你想让你的人标记他们的朋友 在使用您的App发布到Facebook的故事中,您可以使用 / me / taggable_friends API。 使用此端点需要Facebook的审查,并且只能用于您要呈现一个朋友列表的情况,以便让用户在帖子中标记他们。

  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.

如果您的应用程序是游戏,您的游戏支持Facebook Canvas ,您可以使用 / me / invitable_friends 端点,以便呈现自定义邀请对话框,然后将此API返回的令牌传递到标准请求对话框。

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.

在其他情况下,应用无法再检索用户的朋友的完整列表只有那些使用专门授权您的应用程序的朋友user_friends 权限)。 这已被Facebook确认为按设计。

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'.

对于想让人们邀请朋友使用应用程序的应用,您仍然可以使用在Web上发送对话框或新的 iOS上的邮件对话框Android

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在这里发布了有关这些更改的常见问题:一个href =https://developers.facebook.com/docs/apps/faq> https://developers.facebook.com/docs/apps/faq ,它解释了开发人员按顺序可用的所有选项邀请朋友等。

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天全站免登陆