Reputation: 401
Looking for a way to get the profile picture URL's for all of the user's friends. I'm aware of the method of getting each user ID and 'scrolling' through each ID (https://www.graph.facebook.com/3422098/picture), however this needlessly takes up a lot of time.
I'm trying to figure out how to do this with the Batch Request (http://developers.facebook.com/blog/post/2011/03/17/batch-requests-in-graph-api/) and get all of the URL's in one go, unfortunately I can't figure it out.
I can get a list of friends..
NSString *jsonRequest1 = @"{ \"method\": \"GET\", \"relative_url\": \"me/friends\" }";
NSString *jsonRequestsArray = [NSString stringWithFormat:@"[%@]", jsonRequest1];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObject:jsonRequestsArray forKey:@"batch"];
[facebook requestWithGraphPath:@"me" andParams:params andHttpMethod:@"POST" andDelegate:self];
Mutual friends..
NSString *jsonRequest1 = @"{ \"method\": \"GET\", \"relative_url\": \"me/mutualfriends/61309973?limit=20\" }"; NSString *jsonRequestsArray = [NSString stringWithFormat:@"[%@]", jsonRequest1]; NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObject:jsonRequestsArray forKey:@"batch"]; [facebook requestWithGraphPath:@"me" andParams:params andHttpMethod:@"POST" andDelegate:self];
But I can't figure out how to get profile pictures.
Thanks for any help you guys can offer.
Upvotes: 1
Views: 4956
Reputation: 96281
I'm trying to figure out how to do this with the Batch Request […] and get all of the URL's in one go, unfortunately I can't figure it out.
You want to get the actual images?
The Graph API does not return image data, no matter if batch or not. It only returns image URLs.
If you don’t want to have to deal with the redirect the usual /userid/picture URLs give back, then you could query the users albums connection for the album named "profile pictures", and get that album’s photos – that gives you actual URLs that don’t redirect as far as I can see. But that’d require getting the users explicit permission to read their photos …
Upvotes: 0
Reputation: 43816
For all friends ask for /me/friends?fields=name,picture
For mutual friends, ask for /me/mutualfriends/[OTHER ID]/?fields=name,picture
Upvotes: 4