简体   繁体   中英

Facebook Friends Profile Picture who installed the same apps

I need to display Facebook Friends list who installed the same apps. I got the "FriendName" and "FriendID" using "Facebook-Graph-API". But I am not getting "FriendProfile Picture". I am using this code:

[[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:@{@"fields": @"id,name,link,first_name, last_name, picture.type(large), email, birthday,friends,gender,age_range,cover"}]
     startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
         if (!error)
         {
             //NSLog(@"result is :%@",result);
             NSLog(@"User ID : %@",[result valueForKey:@"id"]);
             NSLog(@"User Name : %@",[result valueForKey:@"name"]);
             NSLog(@"User First Name :%@",[result valueForKey:@"first_name"]);
             NSLog(@"User Last Name :%@",[result valueForKey:@"last_name"]);
             NSLog(@"USER Email is :%@",[result valueForKey:@"email"]);

             NSLog(@"User total friends : %@",[[[result valueForKey:@"friends"]objectForKey:@"summary"]valueForKey:@"total_count"]);


             //Friend List ID And Name
             NSArray * allKeys = [[result valueForKey:@"friends"]objectForKey:@"data"];

             fb_friend_Name = [[NSMutableArray alloc]init];
             fb_friend_id  =  [[NSMutableArray alloc]init];

             for (int i=0; i<[allKeys count]; i++)
             {
                 [fb_friend_Name addObject:[[[[result valueForKey:@"friends"]objectForKey:@"data"] objectAtIndex:i] valueForKey:@"name"]];

                 [fb_friend_id addObject:[[[[result valueForKey:@"friends"]objectForKey:@"data"] objectAtIndex:i] valueForKey:@"id"]];

             }
             NSLog(@"Friends ID : %@",fb_friend_id);
             NSLog(@"Friends Name : %@",fb_friend_Name);


         }
     }];

Try this :

NSString *str = [NSString stringWithFormat:@"http://graph.facebook.com/%@/picture?type=large",friend_id];
NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:str]];
UIImage *profilePic = [UIImage imageWithData:imageData];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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