batch request graph api iPhone xcode?

611 views Asked by At

I am going to fetch four or multiple records of from facebook through graph api with batch request like this

NSString *jsonRequest1 = @"{ \"method\": \"GET\", \"relative_url\": \"133028623426021\" }";
        NSString *jsonRequest2 = @"{ \"method\": \"GET\", \"relative_url\": \"152881298125928\" }";
        NSString *jsonRequest3 = @"{ \"method\": \"GET\", \"relative_url\": \"20870926514\" }";
        NSString *jsonRequest4 = @"{ \"method\": \"GET\", \"relative_url\": \"124551187593106\" }";

        NSString *jsonRequestsArray = [NSString stringWithFormat:@"[ %@, %@, %@, %@ ]", jsonRequest1, jsonRequest2,jsonRequest4,jsonRequest3];
        NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObject:jsonRequestsArray forKey:@"batch"];
        FbGraphResponse *fb_graph_response1 = [fbGraph doGraphPost:jsonRequestsArray withPostVars:params];
        NSLog(@"%@",fb_graph_response1.htmlResponse);

But my response is like this

response =

How can i get response through graph api with batch request?

1

There are 1 answers

0
stipe108 On

For request_ids, you do not need to create a batch request. You can simply pass them as a comma separate list and avoid doing a batch request.

NSString *requestIds = @"123456789,987654321";
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObject:requestIds forKey:@"ids"];
[facebook requestWithGraphPath:@"" andParams:params andDelegate:self];

Your final graph URL wants to look like:

https://graph.facebook.com/?ids=REQUEST_ID1,REQUEST_ID2,REQUEST_ID3&access_token=ACCESS_TOKEN