I'm developing an iPhone iOS app with FB connect.
I'm trying to get a lot of data for each of my friends, and multiple requests are needed.
I wonder if there's a way using batch requests in the iOS SDK?
and the other problem with FQL multi-queries. The following query is working only for a limit of one friend! weird.
SELECT eid FROM event_member WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me() LIMIT 2)
it returns the error The operation couldn’t be completed. (facebookErrDomain error 1.)
According this example of facebook it should have been working.
You can do batch requests with the Facebook iOS SDK, but you need to prepare the JSON requests yourself. Here is an example:
-(void) prepareMyBatchRequest {
NSString *jsonRequest1 = @"{ \"method\": \"GET\", \"relative_url\": \"me/friends\" }";
NSString *jsonRequest2 = @"{ \"method\": \"GET\", \"relative_url\": \"me/albums\" }";
NSString *jsonRequestsArray = [NSString stringWithFormat:@"[ %@, %@ ]", jsonRequest1, jsonRequest2];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObject:jsonRequestsArray forKey:@"batch"];
[facebook requestWithGraphPath:@"me" andParams:params andHttpMethod:@"POST" andDelegate:self];
}
- (void)request:(FBRequest *)request didLoad:(id)result {
NSArray *allResponses = result;
for ( int i=0; i < [allResponses count]; i++ ) {
NSDictionary *response = [allResponses objectAtIndex:i];
int httpCode = [[response objectForKey:@"code"] intValue];
NSString *jsonResponse = [response objectForKey:@"body"];
if ( httpCode != 200 ) {
NSLog( @"Facebook request error: code: %d message: %@", httpCode, jsonResponse );
} else {
NSLog( @"Facebook response: %@", jsonResponse );
}
}
}
Concerning your other question, I don't know (try to ask other questions in distinct posts so it's easier to follow-up).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With