iOS OC

afnetworking参数为字符串的请求

2019-06-12  本文已影响0人  流年小书
money为参数(@“10”)
NSString *url = [NSString stringWithFormat:@"%@%@%@",BASEURL2,KPayRequest,userRequestId];
        
NSMutableURLRequest *request = [[AFJSONRequestSerializer serializer] requestWithMethod:@"POST" URLString:url parameters:nil error:nil];
request.timeoutInterval= 30;
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[request setValue:token forHTTPHeaderField:@"oceans-token"];
[request setHTTPBody:[money dataUsingEncoding:NSUTF8StringEncoding]];
        
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
manager.requestSerializer = [AFJSONRequestSerializer serializer];
[[manager dataTaskWithRequest:request uploadProgress:^(NSProgress * _Nonnull uploadProgress) {
        } downloadProgress:^(NSProgress * _Nonnull downloadProgress) {
        } completionHandler:^(NSURLResponse * _Nonnull response, id  _Nullable responseObject, NSError * _Nullable error) {
            if ([[NSString stringWithFormat:@"%@",[responseObject objectForKey:@"resultCode"]] isEqualToString:@"0"]) {
                aSuccess(responseObject);
            }else{
                aFailure(responseObject);
            }
        }] resume];
上一篇下一篇

猜你喜欢

热点阅读