适用于好友列表的Facebook Graph API在iOS上返回nil [英] Facebook Graph API for friends list returns nil on iOS

查看:81
本文介绍了适用于好友列表的Facebook Graph API在iOS上返回nil的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过此代码访问自己的Facebook朋友列表,并且生成的JSON不返回任何数据.

I am trying to access my own Facebook friends list through this code and the resulting JSON does not return any data.

FBRequest *request = [FBRequest requestWithGraphPath:@"me/friends" parameters:nil HTTPMethod:@"GET"];

我正在这样设置权限(我正在使用PARSE)

I am settings the permissions like this (i am using PARSE)

[PFFacebookUtils linkUser:[PFUser currentUser] permissions:@[@"user_friends"] block:^(BOOL succeeded, NSError *error)

我想念什么吗?

推荐答案

您是否正在使用API​​的V2? Facebook最近进行了重大更改,因此此API调用现在仅返回使用过发出请求的应用程序的朋友.换句话说,您无法获取整个朋友列表,只能获取也在使用该应用程序的朋友.

Are you using V2 of the API? Facebook has made a big change recently so that this API call now only returns friends who have used the app that is making the request. In other words, you can't fetch your whole friend list, only friends who are also using the app in question.

更多信息在这里:

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

您可以通过页面右上角的下拉菜单查看1.0版和2.0版之间的区别.

You can see the difference between version 1.0 and version 2.0 using the dropdown on the top right of the page.

如果您使用的是新的2.0 iOS SDK,则FBRequest具有一个实例方法,可针对特定请求使用不同版本的API.

If you are using the new 2.0 iOS SDK, FBRequest has an instance method to use a different version of the API for a specific request.

在这种情况下,您可以先启动请求

In this case, before you kick off the request, you can do

[request overrideVersionPartWith:@"v1.0"];

v1.0页面上所述:

一旦用户使用2.0版(或更高版本)登录到应用程序, 为v1.0调用此边缘将继续返回更高版本的 响应.

Once a user has logged into an app using version 2.0 (or later), calling this edge for v1.0 will continue to return the later version's response.

基本上,为了使此工作有效,您的登录方法也必须是旧的.

Basically, in order to make this work, your login method must also be an old one.

如果这是您需要的功能,则取决于您计划支持该应用的时间,一个更简单的选择可能是至少暂时使用较旧版本的Facebook SDK.它将获得大约一年的支持,届时您的要求可能会发生变化,以便您可以进行更新,或者Facebook可以使我们能够再次获取用户的整个朋友列表,这很不可能.

If this is a functionality you need to have, depending on how long you are planning on supporting this app, an easier option might be just to use an older version of the Facebook SDK, at least for the time being. It will be supported for roughly another year, by which point either your requirements may change so you can just update, or Facebook may provide us with an ability to fetch a user's entire friend list again, which is unfortunately pretty unlikely.

使用旧API的最新版本是3.13.1.

The last version using the old API is 3.13.1.

您还可以使用其他一些可能的选项,具体取决于您尝试对朋友列表进行的操作.此网站上的其他答案中有一堆信息,

There are also some other possible options you may use, depending on what you try trying to do with the friend list. There is a bunch of info in other answers on this site, here is one with a good discussion.

Simon Cross指出了一些我不知道的信息.如果您的应用是2014年4月30日之后创建的,则无论SDK版本还是其他版本,您都无法使用v1.0 API.因此,基本上,此解决方法仅适用于在4月30日之前已在其应用程序中使用1.0 API的用户.

Simon Cross pointed out a bit of info which I did not know. If your app was created after April 30th, 2014, you can't use the v1.0 API at all, regardless of SDK version or anything else. So basically, this workaround is only for people who were already using the 1.0 API in an app of theirs before April 30th.

这篇关于适用于好友列表的Facebook Graph API在iOS上返回nil的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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