FBFriendPickerViewController to save friends pictures
-
11-12-2019 - |
سؤال
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"]
.
المحلول 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];
}];
نصائح أخرى
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);
}
}
لا تنتمي إلى StackOverflow