0

这是我的代码,我打印地址,当我在浏览器中从 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);
    }];
}

已解决:将 api 替换为 https://

4

1 回答 1

0

已解决:将 api 替换为 https://

于 2016-10-04T10:02:21.217 回答