POST

    

   
    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);

 

posted @ 2014-01-15 11:10  TianXiang.Liu  阅读(178)  评论(0编辑  收藏  举报