代码改变世界

post请求

2015-04-21 09:43  可小猪  阅读(236)  评论(0编辑  收藏  举报

宋鹏鹏 09:34:54
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.requestSerializer = [AFHTTPRequestSerializer serializer];
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
// manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/plain"];
NSDictionary *data = [[NSDictionary alloc]init];
NSString *str =[NSString stringWithFormat:@"http://123.57.1.143/api/user/%@/show",uid];

[manager POST:str parameters:data success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSString *html = operation.responseString;
NSData* data=[html dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *dict=[NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
// NSLog(@"获取到的数据为:%@",dict);


_userDataDic = dict;

//NSLog(@"成功%@",dict);

} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"失败%@", error);

//listActivityIndicator.hidden = NO;

 

自己在下个afn