Niharika
Niharika

Reputation: 1198

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);


         }
     }];

Upvotes: 0

Views: 40

Answers (1)

vegda neel
vegda neel

Reputation: 154

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];

Upvotes: 1

Related Questions