Revision: 22745
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at January 20, 2010 18:25 by tbass134
Initial Code
NSURL *url = [NSURL URLWithString:@"http://server.com/file.php"]; NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60]; [req setHTTPMethod:@"POST"]; [req setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; NSString *postData = [NSString stringWithFormat:@"page=%@¶m1=%@¶m2=%@param3=%@", @"item1", @"item 2",@"item 3",@"item 4"]; NSString *length = [NSString stringWithFormat:@"%d", [postData length]]; [req setValue:length forHTTPHeaderField:@"Content-Length"]; [req setHTTPBody:[postData dataUsingEncoding:NSASCIIStringEncoding]]; NSHTTPURLResponse* urlResponse = nil; NSError *error = [[[NSError alloc] init] autorelease]; NSData *responseData = [NSURLConnection sendSynchronousRequest:req returningResponse:&urlResponse error:&error]; NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSASCIIStringEncoding];
Initial URL
Initial Description
Initial Title
NSMutableURLRequest Send Variables to Script
Initial Tags
Initial Language
Objective C