批量请求图api iPhone xcode?

发布于 2025-01-01 10:17:01 字数 980 浏览 1 评论 0原文

我将通过像这样的批量请求通过图形 api 从 facebook 获取四个或多个记录

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);

但我的响应是这样的

response =

我如何通过图形 api 获得响应批量请求?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

人间☆小暴躁 2025-01-08 10:17:01

对于request_ids,不需要创建批量请求。您可以简单地将它们作为逗号分隔列表传递,并避免执行批量请求。

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

您的最终图表 URL 应该是这样的:

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

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文