Delay in facebook graph api answers
I'm using the graph api in iOS. I'm sending request to each of the user's friends in FB for their current events:
for( NSDictionary *friend in friends ) {
NSLog(@"sending events request for %@", [friend objectForKey:@"id"]);
[facebook requestWithGraphPath:
[NSString stringWithFormat:@"%@/events&since=today&until=tomorrow&limit=10", [friend obj开发者_C百科ectForKey:@"id"]]
andDelegate:self];
}
for the first answer there is delay of 5 seconds and the last answer comes after two (!!) minutes or so (for 500 requests - 500 friends).
Is the facebook making this delay on purpose or there is other option here getting all the information at once?
Thanks a lot!
I'm wondering if you know about the Facebook batch API? It is intended for use when you will make multiple requests. I did a brief search but can't find a good link to point you at so I recommend just googling a bit more deeply.
The other thing to consider is putting your web requests into another thread that you kick off in the background, notifying your main thread (with the UI) when new data is available so your display can be updated. Like ceejayoz says, 500 requests is a lot, chances are there is some rate limiting going on. Using a thread won't make what you are doing any nicer from their point of view but you will be able to minimize the impact to your users that the delay causes.
Details on the Facebook batch API:
https://developers.facebook.com/docs/reference/api/batch/
Also this SO question has a good answer on how to use the Facebook iOS SDK to do a batch request:
Facebook connect Batch requests and FQL error problem
Note that the Batch Api currently allows a max of 20 requests per batch, so you would still have to make 25 requests (500/20).
精彩评论