AFNetworking3.0 POST请求

来源:互联网 发布:淘宝大学免费帐号 编辑:程序博客网 时间:2024/05/16 10:34
1  // 请求管理者 2     AFHTTPSessionManager *manager = [AFHTTPSessionManager manager]; 3     manager.responseSerializer = [AFHTTPResponseSerializer serializer]; 4      5      6     // 拼接请求参数 7     NSMutableDictionary *params = [NSMutableDictionary dictionary]; 8     params[@"client_id"] = @"2331570398"; 9     params[@"client_secret"] = @"240608336b729e27685af0ec496c1a60";10     params[@"grant_type"] = @"authorization_code";11     params[@"redirect_uri"] = @"http://";12     params[@"code"] = code;13 14 15     16     17     [manager POST:@"https://api.weibo.com/oauth2/access_token" parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {18         19     } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {20         NSLog(@"请求成功:%@", responseObject);21         22         NSDictionary *JSON = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];23         24         NSLog(@"请求成功JSON:%@", JSON);25 26         27     } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {28         29         NSLog(@"请求失败:%@", error.description);30 31     }];32     
0 0