这是我的代码,我打印地址,当我在浏览器中从NSLOG输入地址时,它会显示所需的数据,但在我的代码中,有错误。
+(void)getCityInformationByCityName:(NSString *)namer
successBlock:(void (^)(NSDictionary *response))successHandler
errorBlock:(void (^) (NSDictionary *error))errorHandler
{
NSString *apiKey = [[NSUserDefaults standardUserDefaults] objectForKey:@"apiKey"];
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
manager.requestSerializer = [AFHTTPRequestSerializer serializer];
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
NSString *url = [NSString stringWithFormat:@"api.openweathermap.org/data/2.5/weather?q=%@&APPID=%@", namer, apiKey];
NSLog(@"%@", url);
[manager GET:url parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
successHandler(responseObject);
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
NSDictionary *userInfo = [error userInfo];
errorHandler(userInfo);
}];
}
已解决:用https://
替换了api答案 0 :(得分:0)
已解决:用https://
替换了api