1

Ive been pulling my hair out for the last week on this now, and still not getting any closer.

Im building an app for my university project, where it combines all the services into one, (Blackboard, Intranet, Email) These all have seperate logins, on seperate web pages.

Im aiming to combine all these services into one app, with only one centralised log in. However the log in will simply not work for me at all, they use a form based log in, with a javascript background.

Ive tried ASIHTTP:

-(void)startWebViewLoad{
NSString *emailURL = @"https://home.swan.ac.uk";
NSURL *url = [NSURL URLWithString:emailURL];

ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setPostValue:@"username" forKey:@"user_name"];
[request setPostValue:@"password" forKey:@"password"];


NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[webViewEmail loadRequest:requestObj];

I may have put this in the wrong part of the code (Im displaying the page after login in a UIWebView) But this will not log me in it all.

Is there a better way to log in using the form? Or am I close with my current code

Thank you for your time

Josh
  • 37
  • 6

1 Answers1

0

You create the request but never send it. Add after creating the request object:

    [request setRequestMethod:@"POST"];
    [request setDelegate:self];
    [request start];

Warning: this will block the UI while the request runs. It's better to use [request startAsynchronous], but this will require you to refactor your code.

Richard Brown
  • 11,346
  • 4
  • 32
  • 43
  • Will this work for displaying the website logged in, in UIWebView? Thankyou for your answer – Josh Apr 22 '13 at 14:58
  • You know, I was so busy fixing the code that I ignored your intent. :p In reality take a look at [this question](http://stackoverflow.com/questions/8999776/how-to-do-authentication-in-uiwebview-properly) as a better way to authenticate `UIWebView`. – Richard Brown Apr 22 '13 at 15:02
  • Ive just looked through this, but it seems it is to be used for a "pop-up"log in box. The website i am attempting to log into does not have this, it just has the login form embedded into the webpage. I do greatly appreciate your help, thankyou – Josh Apr 25 '13 at 13:49
  • By "pop-up" I mean authentication challenge, the words just would not come to me when typing – Josh Apr 25 '13 at 14:02