Question

Is it possible to get friends userpics using FBFriendPickerViewController? I tried:

FBFriendPickerViewController *friendPicker = [[FBFriendPickerViewController alloc] init];
friendPicker.fieldsForRequest = [[NSSet alloc] initWithObjects:@"picture", nil];
[friendPicker loadData];
[friendPicker presentModallyFromViewController:self
                                      animated:YES
                                       handler:^(FBViewController *sender, BOOL donePressed) {
                                           if (donePressed) {
UIImage *pic = friend[@"picture"];
...

But there is nil in friend[@"picture"].

Was it helpful?

Solution 2

Solution

NSURL *profilePictureURL = [NSURL URLWithString:friend[@"picture"][@"data"][@"url"]];
                                                               NSURLRequest *profilePictureURLRequest = [NSURLRequest requestWithURL:profilePictureURL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:10.0f]; // 

                                                               [NSURLConnection sendAsynchronousRequest:profilePictureURLRequest
                                                                                                  queue:[NSOperationQueue mainQueue]
                                                                                      completionHandler:^(NSURLResponse* response, NSData* receivedData, NSError* error)
                                                                {
                                                                    UIimage *userpic = [UIImage imageWithData:receivedData];
                                                                }];

OTHER TIPS

Try this code inside your block, here i got it working.

if (donePressed) {
   for (id<FBGraphUser> user in self.friendPickerController.selection) {
        UIImage *pic = user[@"picture"];
        NSLog(@"%@",pic);                                              
   }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top