Search code examples
iosasihttprequest

ASIHTTPRequest how do i login?


Hello hello fellow programmers,

Intro: Im trying to write an app (in obj-C,with X-code), that allows me to log into a website and do some stuff on this website. I know C and C++, but this is my first "real app" that i am trying to write. Im trying to get it to work on my mac first, then i want to write the same app for IOS.

The website is https://www.mymeteor.ie

1)Login

NSURL *LOGIN_URL;
LOGIN_URL = [NSURL URLWithString:@"https://www.mymeteor.ie/go/mymeteor-login-manager"];

ASIFormDataRequest *request;

request = [ASIFormDataRequest requestWithURL:LOGIN_URL];    
[request setPostValue:@"**********" forKey:@"msisdn"]; //username
[request setPostValue:@"****" forKey:@"pin"];          //password
[request startSynchronous];

The status code which this request returns when i enter the correct username and password is 200 and the response string is the next webpage which you can only receive if you are logged in.

But if i enter a different username and password the status code is still 200, but the response string is the login page again.

How do i check if i am logged in? Once i am logged in i want to use the FreeWebText thingy on the site.

What would be the best way to do this?any tips?

Thank you for your help


Solution

  • You'll want to see if MyMeteor has an API. The API will be their preferred way for 3rd party apps to log in and interact with the site. Instead of returning a whole webpages html, the api would likely return some sort of authorization code, or an error if the login isn't correct.

    If they don't have an API, you would need to scrape the HTML that's returned. You should be able to find unique differences between the two pages that will tell you if you actually logged in or not. This is pretty unreliable, since anytime they change the site it could break your scraping.