post 传字典

NSString *urlStr = [GNConfig loadWebUrlWithKey:@"KeyLoginUrl"];

    

    NSString *paraStr = [NSString stringWithFormat:@"user=%@&pwd=%@",user.userid,user.passWord];

    NSData *postData = [paraStr dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];

    NSString *postLength = [NSString stringWithFormat:@"%zd", [postData length]];

    

    NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];

    [request setURL:[NSURL URLWithString: urlStr]];

    [request setCachePolicy:NSURLRequestReloadIgnoringCacheData];

    [request setTimeoutInterval: 10];

    [request setHTTPShouldHandleCookies:FALSE];

    [request setValue:postLength forHTTPHeaderField:@"Content-Length"];

    [request setHTTPBody:postData];

    [request setHTTPMethod:@"POST"];

你可能感兴趣的:(post 传字典)