我正在尝试使用 UNIRest API 在 iPhone 应用程序中运行此获取请求
https://api.guildwars2.com/v1/guild_details.json?guild_name=The%20Legacy
我正在运行的代码是这样的
NSDictionary* headers = @{@"accept": @"application/json"};
NSDictionary* parameters = @{@"guild_name": @"The Legacy"};
UNIHTTPJsonResponse* response = [[UNIRest post:^(UNISimpleRequest* request) {
[request setUrl:@"https://api.guildwars2.com/v1/guild_details.json"];
[request setHeaders:headers];
[request setParameters:parameters];
}] asJson];
NSDictionary *guildInformation = response.body.JSONObject;
NSLog(@"response length: %lu", (unsigned long)[guildInformation.allValues count]);
for(NSString *key in [guildInformation allKeys]) {
NSLog(@"key: %@ object: %@", key, [guildInformation objectForKey:key]);
}
我曾希望 for 循环会显示响应。但是,当您看到唯一的输出是,我似乎根本没有得到任何回应,
response length: 0
我不太了解 UNIRest API 来解决这个问题,也找不到任何好的文档。我究竟做错了什么?