[VB.NET] [HTTPWrapper] Gaiaonline Login
Difficulty (7-10)
I recommend you are intermediate in Visual Basic.
This tutorial will be using my VB.NET Wrapper found here.
The benefit of using a wrapper is the amount of lag it reduces compared to the webBrowser control.
With websites there are 2 kinds of requests a POST and a GET. POST will post information and the get will just simply go to a url.
Logging into Gaia uses a POST statement. To record this post statement you need to use FireFox and install the addon Live HTTP Headers.
Downloads.
After you are in FireFox head over to Log In | Gaia Online.
Now you need to hit tools and open Live HTTP Headers.
Make sure that "Capture" is checked.
Next use a valid Gaia account and login. Make sure that the Live HTTP Headers is open to log.
After you login you will see this.
http://k.min.us/idN2uU.png
Right click and copy the highlighted line in the picture.
It will be something like this.
Code:
token=279461850.1310153733.1533427493&sid=621b3d75ilkcrp2fcj5rkyv4zv6mqk4o&redirect=&username=Username&password=Password&chap=291259aee0173ea7162ad6c0c93f1abe
Of coarse where username and password will be your test account.
Heres how i learned to use the wrapper with gaia login.
Code:
If Wrapper.post("http://www.gaiaonline.com/auth/login", "username=USERNAME&password=PASSWORD&token=" & Wrapper.Between(Wrapper.[Get]("http://www.gaiaonline.com/auth/login"), "token"" value=""", """") & "&chap=" & Wrapper.Between(Wrapper.[Get]("http://www.gaiaonline.com/auth/login"), "chap"" value=""", """"), "http://www.gaiaonline.com/").IndexOf("Logout") > -1 Then
Label1.Text = "Logged in"
Else
Label1.Text = "Failed"
End If
Not let me explain this code part by part...
Code:
Wrapper.post("http://www.gaiaonline.com/auth/login", "username=USERNAME&password=PASSWORD&token=" & Wrapper.Between(Wrapper.[Get]("http://www.gaiaonline.com/auth/login"), "token"" value=""", """") & "&chap=" & Wrapper.Between(Wrapper.[Get]("http://www.gaiaonline.com/auth/login"), "chap"" value=""", """")
The bolded text is what is being POSTed to the server. Compare this to the statement you found using LiveHTTP Header.
Now there are two parts of this you should understand for future reference.
Code:
"token"" value=""", """") & "&chap=" & Wrapper.Between(Wrapper.[Get]("http://www.gaiaonline.com/auth/login"), "chap"" value=""", """")
Now these two parts of the post statement are different every time and you are required to "catch" the new one every time. To catch these you need to use Wrapper.Between. The Between will look between characters to collect a value. So in "chap" for example.
Code:
"token"" value=""", """") & "&chap=" & Wrapper.Between(Wrapper.[Get]("http://www.gaiaonline.com/auth/login"), "chap"" value=""", """")
Wrapper.Between Accepts two arguments, in this case it is the GaiaLogin page and what you are looking for.
Im sorry if that is not a thorough enough of, thats as far as i can think to go.
Now to make this work for your program, chose how you would like to collect the usernames and passwords to use in your program.
If you are going to use a console, declare 2 string name them something like "user","pass".
Using a textbox would look like this, i suggest to name the textboxs properly so it is not just "Textbox1".
Code:
If Wrapper.post("http://www.gaiaonline.com/auth/login", "username=USERNAME&password=PASSWORD&token=" & Wrapper.Between(Wrapper.[Get]("http://www.gaiaonline.com/auth/login"), "token"" value=""", """") & "&chap=" & Wrapper.Between(Wrapper.[Get]("http://www.gaiaonline.com/auth/login"), "chap"" value=""", """"), "http://www.gaiaonline.com/").IndexOf("Logout") > -1 Then
Label1.Text = "Logged in"
Else
Label1.Text = "Failed"
End If
Now add this code to a button click or what ever you want it to activate on.
I will post an example for download so you can see this in full use.
-Download-
Sorry if this got confusing.