简体   繁体   English

检索Facebook好友列表

[英]Retrieve Facebook friends list

I want to retrieve the user's friends list from Facebook. 我想从Facebook检索用户的好友列表。 Any sample code will be highly appreciated. 任何示例代码都将受到高度赞赏。

after login, do this- [facebook requestWithGraphPath:@"me/friends" andDelegate:self]; 登录后,这样做 - [facebook requestWithGraphPath:@“me / friends”andDelegate:self]; //the friends data should be parsed in this delegate method. //应该在此委托方法中解析好友数据。

- (void)request:(FBRequest *)request didLoad:(id)result {

    if([result isKindOfClass:[NSDictionary class]])
    {
        NSLog(@"dictionary");
        result=[result objectForKey:@"data"];
        if ([result isKindOfClass:[NSArray class]]) 

            for(int i=0;i<[result count];i++){

                NSDictionary *result2=[result objectAtIndex:i];
                NSString *result1=[result2 objectForKey:@"id"];                     NSLog(@"uid:%@",result1);
                [uids addObject:result1];
            }
    }
}

here, i added all the friends uids to an array. 在这里,我将所有朋友的uids添加到一个数组中。 same way u can get names and perform any using GraphApi . 同样的方式你可以使用GraphApi获取名称并执行任何操作。

Hope it helped u.. 希望它对你有所帮助..

use graph api to requestwithgraphapi string @"me/friends" . 使用graph apirequestwithgraphapi string @“me / friends”

this is for signed user friends. 这是为已签名的用户朋友。

friendlists 好友列表

The user's friend lists 用户的好友列表

Requires permissions of "read_friendlists" to read & "manage_friendlists" to write 需要“read_friendlists”权限才能读取和“manage_friendlists”进行编写

so add them to ur permission array 所以将它们添加到ur权限数组

array of objects containing id and name fields of the friendlist 包含friendlist的id和name字段的对象数组

使用FacebookGraph API获取用户的好友列表

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM