Reputation: 224
I am adding facebook functionality to my app, and I am using the SDK provided by Facebook.
I log in using the [facebook authorize:nil]
call, and retrieving the user's friends list making a call to the graph API: [facebook requestWithGraphPath:@"me/friends" andDelegate:self]
However, afterwards I would like to fetch every one of user's friends details and profile picture. Right now I am doing it making this call:
-(void)getDetailedInfoForFacebookUser:(NSArray *)aIDArray
{
for (NSString *aID in aIDArray) {
[facebook requestWithGraphPath:aID andDelegate:self];
[facebook requestWithGraphPath:[NSString stringWithFormat:@"%@/picture",aID] andDelegate:self];
}
}
But the response time is way to long because for the typical user (around 500 friends) there are more than 1000 responses to parse. Is there any way to retrieve all this info not making such a ridiculous amount of requests?
Thanks a lot for the help!
Upvotes: 1
Views: 823
Reputation: 224
Using FQL you can make bulk requests and parse all at once!
-(void) startFriendsRequest
{
// Construct your FQL Query
NSString* fql = [NSString stringWithFormat:@"SELECT uid,name,first_name,middle_name,last_name,pic_square FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())"];
// Create a params dictionary
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObject:fql forKey:@"query"];
// Make the request
[facebook requestWithMethodName:@"fql.query" andParams:params andHttpMethod:@"GET" andDelegate:self];
}
Upvotes: 2
Reputation: 70
You don't need to create an additional Facebook Graph request to get a user picture... Just load your image from
https://graph.facebook.com/<User ID or login name>/picture
Optionally ?type=square | small | normal | large
Upvotes: 0