AFN post请求

作者: 凤鹃一鸣 | 来源:发表于2016-12-20 10:16 被阅读53次

    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];

    manager.requestSerializer = [AFHTTPRequestSerializer serializer];

    manager.responseSerializer = [AFHTTPResponseSerializer serializer];

    manager.requestSerializer.timeoutInterval = 10;

    [manager POST:[NSString stringWithFormat:@"%@/login/validatePhone",MGHZSUrl] parameters:dic progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {

    NSDictionary *dictArray = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers|NSJSONReadingMutableLeaves error:nil];

    MGLog(@"POST成功:%@",dictArray);

    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {

    MGLog(@"POST失败原因:%@",error);

    NSData *data = error.userInfo[@"com.alamofire.serialization.response.error.data"];

    NSString *String = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];

    MGLog(@"失败原因:%@",String);

    }];

    相关文章

      网友评论

        本文标题:AFN post请求

        本文链接:https://www.haomeiwen.com/subject/uzuxvttx.html