//如果请求地址中出现中文需要进行url编码
NSString *path = @"http://apis.juhe.cn/cook/query?key=80996127f667eac43832103850b3b13a&menu=鱼";
path = [path stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
NSURL *url = [NSURL URLWithString:path];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
NSURLSession *session = [NSURLSessionsharedSession];
NSURLSessionDataTask *task = [sessiondataTaskWithRequest:requestcompletionHandler:^(NSData *_Nullable data, NSURLResponse *_Nullable response,NSError * _Nullable error) {
NSDictionary *dic = [NSJSONSerializationJSONObjectWithData:dataoptions:0error:nil];
NSLog(@"%@",dic);
}];
[task resume];
NSString *path = @"http://apis.juhe.cn/cook/query";
NSDictionary *paramsDic = @{@"key":@"80996127f667eac43832103850b3b13a",@"menu":@"鱼"};
AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc]init];
[manager setResponseSerializer:[AFHTTPResponseSerializer serializer]];
[manager GET:path parameters:paramsDic progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:responseObject options: 0 error:nil];
NSLog(@"%@",[NSThread currentThread]);
NSLog(@"%@",dic);
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
}];
[manager POST:path parameters:paramsDic progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
}];