1

我收到未经授权的 BBVA APIData 错误。我在 Xcode 中用作 Objective-C 来获取数据的代码是这样的:

NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];

[request setURL:[NSURL URLWithString:@"https://api.bbva.com/apidatos/zones/cards_cube.json?date_min=201301&date_max=201307&group_by=week"]];

[request setHTTPMethod:@"GET"];

[request setValue:@"application/json;charset=UTF-8" forHTTPHeaderField:@"Authorization: Y2hvbWFsaS1hcHA6MGM2ZTljNjgxODNiZmUzOWY2OGJiYjY1NjZlZmU4ZTE3MzI0NTcyOQ=="];

NSURLResponse *response;

NSData *GETReply = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:nil];

NSString *theReply = [[NSString alloc] initWithBytes:[GETReply bytes] length:[GETReply length] encoding: NSASCIIStringEncoding];

NSLog(@"Reply: %@", theReply);

这是我使用的文档:https ://developer.bbva.com/api/api-datathon/section/api-reference

4

1 回答 1

0

我认为,在第 4 行,它应该是

 [request setValue: Y2hvbWFsaS1hcHA6MGM2ZTljNjgxODNiZmUzOWY2OGJiYjY1NjZlZmU4ZTE3MzI0NTcyOQ== forHTTPHeaderField:@"Authorization:"];

您可能必须在“授权:”之后删除冒号

于 2013-11-04T02:41:20.217 回答