开发者

how to get facebook friend list using new graph API

i am currently develop an app in which i need to add friend's from facebook friend list using new facebook graph API.

This is my code:

 _permissions = [[NSArray arrayWithObjects:
                         @"read_stream", @"publish_stream", @"offline_access",@"read_friendlists",nil] retain];

[facebook authorize:_permissions];

facebook = [[Facebook alloc] initWith开发者_StackOverflow中文版AppId:@"fbid" andDelegate:self];


[facebook requestWithGraphPath:@"me" andDelegate:self];
[facebook requestWithGraphPath:@"me/friends" andDelegate:self];
NSMutableDictionary*params = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"4",@"uids", @"name", @"fields", nil];
[facebook requestWithMethodName:@"user.getInfo" andParams:params andHttpMethod:@"GET" andDelegate:self];

but every time it give me error in console

please help me...


Here you have a code sample that fetches the friends info:

        [facebook requestWithGraphPath:@"me/friends" 
                             andParams:[ NSDictionary dictionaryWithObjectsAndKeys:@"picture,id,name,link,gender,last_name,first_name",@"fields",nil]
                           andDelegate:self];

Remember to:

  1. implement the proper delegate methods
  2. You must call authorize before fetching the friends information. This way the user will be able to login first.

I hope this helps, cheers


I think you should swap. Otherwise it's not working.

this is correct way:

 facebook = [[Facebook alloc] initWithAppId:@"fbid" andDelegate:self];
 [facebook authorize:_permissions];


   $friend_list =json_decode(file_get_contents("https://graph.facebook.com/$uid/friendlists?access_token=$access_token"),true);
   $friend_list_array = $friend_list['data'];
    foreach($friend_list_array as $key=> $value){
$inner_array_name[$value['id']][]=$value['name'];
        }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜