// http://api.hudong.com/iphonexml.do?type=focus-c
//post请求中url不带请求参数,请求参数在参数HTTPBody中设置, 需要创建可变的url请求,设置请求方式为post
//创建url
NSURL *url = [[NSURL alloc] initWithString:@"http://api.hudong.com/iphonexml.do"];
//创建可变的url请求
NSMutableURLRequest *mRequest = [[NSMutableURLRequest alloc] initWithURL:url];
//设置请求方式为POST
mRequest.HTTPMethod = @"POST";
//设置请求参数
NSString *sendString = @"type=focus-c”;
//HTTPBody为NSData类型, 所以需要将NSString类型转换为NSDate类型
mRequest.HTTPBody = [sendString dataUsingEncoding:NSUTF8StringEncoding];
//发送同步请求
NSData *data = [NSURLConnection sendSynchronousRequest:mRequest returningResponse:nil error:nil];
//将NSData转换为NSString类型
NSString *string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"%@", string);