获取用户的Facebook好友列表 [英] Getting the user’s Facebook list of friends

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

问题描述

能够创建一个登录到Facebook的小型iOS应用程序之后.我希望这个应用程序可以获取用户的好友列表.

After being able to create a small iOS app that logs in to Facebook. I would like this app to get the user’s list of friends.

尽管我浏览了一段时间,并尝试了各种方法,但未能成功获得想要的东西.

Though I browsed the internet for a while and tried various approach I did not succeed to get what I wanted.

在viewDidLoad方法中,我使用以下代码开头:

In the viewDidLoad method I use this code to start with:

loginView = [[FBLoginView alloc] initWithReadPermissions:@[@"user_friends"]];

然后我以这种方式实现loginViewFetchedUserInfo:user:方法:

And then I implement the loginViewFetchedUserInfo: user: method this way:

- (void)loginViewFetchedUserInfo:(FBLoginView *)loginView
                            user:(id<FBGraphUser>)user
{
    [FBRequestConnection startWithGraphPath:@"/me/friends"
                                 parameters:nil
                                 HTTPMethod:@"GET"
                          completionHandler:^(
                                              FBRequestConnection *connection,
                                              id result,
                                              NSError *error
                                              ) {
                              NSLog(@"Result: %@",result);
                          }];
}

当我执行该应用程序时,我得到以下结果:

When I execute the app I get this result:

Result: {
    data =     (
    );
    summary =     {
        "total_count" = 267;
    }; }

但是我真正想要的是一个朋友的名单以及他们的名字……等等…… 我为此所做的所有尝试均无效.尽管我认为解决方案必须很简单.

But what I really want is a list of the friends with their names …etc… All the things I tried for that didn’t work. Though I suppose the solution must be simple.

我在上面的方法中也使用了这样的代码……..但运气不佳:

I also used code like this in the method above ….. but with no luck:

NSArray* friends = [result objectForKey:@"data"];

还有一点,请在这里 https://developers .facebook.com/docs/graph-api/reference/v2.1/user/friends 可以阅读:

One more point, here https://developers.facebook.com/docs/graph-api/reference/v2.1/user/friends one can read:

这只会返回所有使用过的朋友(通过Facebook登录) 发出请求的应用.

This will only return any friends who have used (via Facebook Login) the app making the request.

但是我得到的结果(267)与该语句不匹配.它(267)是用户在Facebook上拥有的朋友数量,实际上我对此很感兴趣.

But the result I get (267) does not match this statement. It (267) is the number of friends the user has on Facebook, which is in fact what I am interested in.

我希望有人能说些什么使我走上正确的道路,并使事情变得更清楚.

I hope someone has something to say to put me on the right track and make things clearer.

推荐答案

自从Facebook的2.x SDK升级以来,他们已经加强了对"Open Graph API"中信息的访问. 在不需要审核的权限

Since Facebook's 2.x SDK upgrade they have tightened up access to information in the "Open Graph API."
Under Permissions That Do Not Require Review

应用程序朋友.此可选权限使您的应用能够读取也使用您的应用的朋友列表.

App friends. This optional permission grants your app the ability to read a list of friends who also use your app.

您可以自动访问已经使用您的应用程序的所有朋友(根据其Facebook ID.)
您将必须请求 扩展权限 ,如果您想访问 all 用户的朋友列表.这意味着要经历Facebook的应用程序审核流程,这可能会非常具有挑战性(而且很烦人.)
坦白说,我什至不确定是否可以使用新的Open Graph API来获取用户的整个朋友列表.

You get automatic access to any friends that already use your app (per its Facebook ID.)
You will have to request Extended Permissions if you want to access the list of all a user's friends. That means going through Facebook's App Review process which can be quite challenging (and annoying.)
Frankly, I am not even sure that it is possible to use the new Open Graph API to get the user's entire friend list.

这篇关于获取用户的Facebook好友列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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