NSURL *url = [NSURL URLWithString:@"https://www.baidu.com"]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; request.HTTPMethod = @"POST"; // 请求参数 NSString *bodyStr = [NSString stringWithFormat:@"username=%@&password=%@", username, password]; request.HTTPBody = [bodyStr dataUsingEncoding:NSUTF8StringEncoding]; NSData *data =[NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSError *error = nil; NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:&error]; NSLog(@"---------------%@", json);