Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to log into a site using objective c
    primarykey
    data
    text
    <p>I'm working on a project where I need to log into a site, retrieve a URL after logging in and parse the data. So far I have been able to parse some of the site data I need without logging in, but now I need to log in to retrieve the rest of the data.</p> <p>I'm not sure how log in and store the session so I can retrieve another URL. The response I get from the the following code does not contain any data. The responseData and responseString are empty.</p> <pre><code>- (void) login { NSMutableURLRequest *loginRequest = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://www.theSite.com/booker/admin.php"]]; NSString *postString = @"go=1&amp;NewUserName=testUserName&amp;NewUserPassword=testPassword&amp;returl=http://www.theSite.com/booker/day.php?day=12&amp;month=08&amp;year=2012&amp;area=0&amp;room=3&amp;TargetURL=http://www.theSite.com/booker/day.php?day=12&amp;month=08&amp;year=2012&amp;area=0&amp;room=3&amp;day.php?day=12&amp;month=08&amp;year=2012&amp;area=0&amp;room=3&amp;Action=SetName"; [loginRequest setHTTPMethod:@"POST"]; [loginRequest setValue:[NSString stringWithFormat:@"%d", [postString length]] forHTTPHeaderField:@"Content-length"]; [loginRequest setHTTPBody:[postString dataUsingEncoding:NSUTF8StringEncoding]]; [[NSURLConnection alloc] initWithRequest:loginRequest delegate:self]; } - (void) connectionDidFinishLoading:(NSURLConnection *)connection { responseData = [NSMutableData new]; NSString* responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]; NSLog(@"the html was %@", responseString); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload