I am creating an iPhone application that retrieves a specific page from a website, but in order to be able to view this website, you need to log in with a username and password.
I created this code:
NSString *urlAddress = @"http://www.wdg-hamburg.de";
NSURL *url = [NSURL URLWithString:urlAddress];
NSString *post = @"name=loginname&pass=pass&form_id=user_login&op=Anmelden";
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding];
NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod: @"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
[vPlan loadRequest:request];
But I did not enter UIWebView!
I register NSHTTPCookieStorageon the console and it shows me the necessary cookie, but I am not logged in.
Does anyone know how I can fix this?
Yours faithfully,
and. Miladinovich
source
share