Hi, I'm new in programming for iPhone and I have a problem. I have a website with login form and I want to write a program on iPhone which open this website without authentication. I thought to launch a brwoser from my application and send a POST data with username and password, but I have no idea how to do that. I can launch browser with url using this code: NSURL *url = [NSURL URLWithString: @"https://www.example.com/index.php"]; [[UIApplication sharedApplication] openURL: url]; but I don't know how to send post data. I tried also another solution: send post data from my application to website and then get a response, but then I don't know how to open returned page in browser. I used this code: NSString *postString = [[NSString alloc] initWithFormat:@"username=%@&password=%@", [self urlEncodeValue: username], [self urlEncodeValue: password]]; NSData *requestData = [NSData dataWithBytes: [postString UTF8String] length: [postString length]];
NSURL *url = [NSURL URLWithString: @"https://www.example.com/index.php"]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL: url]; [request setHTTPMethod: @"POST"]; [request setValue: @"application/x-www-form-urlencoded" forHTTPHeaderField: @"Content-Type"]; [request setHTTPBody: requestData]; NSURLResponse *response; NSError *error; NSData *returnData = [NSURLConnection sendSynchronousRequest: request returningResponse: &response error: &error]; NSString *dataReturned = [[NSString alloc] initWithData: returnData encoding: NSASCIIStringEncoding]; I will be appreciate of any help. Best regards Bartosz Bialecki ---------------------------------------------------- Wiedza. Wikipedia. Encyklopedia. Zrozum otaczający Cię świat: http://klik.wp.pl/?adr=http%3A%2F%2Fwikipedia.wp.pl&sid=857 _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com