AFN 請求 並設定acceptableContentTypes

weixin_33724059發表於2017-07-31
 // 1.拼接請求引數
    NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
    parameters[@"type"] = type;
    parameters[@"userid"] = userid;
    parameters[@"tid"] = tid; //時間戳
    parameters[@"vid"] = vid;  //版本ID
    parameters[@"version"] = version;
    parameters[@"sysid"] = sysid; //專案ID
    parameters[@"keystr"] =keystr ;

 
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.requestSerializer.timeoutInterval = 20.f;
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", @"text/html", @"text/xml", @"text/plain", nil];
   
    //2.傳送GET請求
    [manager POST:str parameters:parameters progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
        NSString *sign = responseObject[@"info"][@"sign"];
        NSString *nonce = responseObject[@"info"][@"nonce"];

        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        NSLog(@"請求失敗--%@",error);
    }];
    

相關文章