CnS Login & Account Info

This is a seperate project based on the sidebar from CnS Desktop. Its standalone and any sidebar addins made for desktop will also function in this sidebar.
12 posts Page 1 of 2
Contributors
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4389
Joined: Tue Aug 04, 2009 1:47 am

CnS Login & Account Info
CodenStuff
Hello,

This is a short guide on how you can use your apps to login to Codenstuff.com and retreive some information from the users account to display in your apps.

Ok to do this you will need to use the basic "API" ive made and the following code. First you will need to add a webbrowser to your form and change its URL propertie to:
Code: Select all
http://www.codenstuff.com/forum/Cnsapiohmy.php
Thats a page that contains some information from your account.

Now when your browser goes to this page if your not logged in you can use the following code to login, using 2 textboxs with your username/password:
Code: Select all
WebBrowser1.Document.GetElementById("prime_login_password").SetAttribute("value", TextBox2.Text)
            WebBrowser1.Document.GetElementById("prime_login_username").SetAttribute("value", TextBox1.Text)
            WebBrowser1.Document.GetElementById("prime_login_auto").InvokeMember("click")
            WebBrowser1.Document.GetElementById("Login").InvokeMember("click")
That will log you in and keep you logged in.

Now to read your account information from that page and place it into your application in labels/textboxs or whatever you can use this quick code.

First add this small function anywhere you want within your app code:
Code: Select all
Public Function GetProfileInfo(ByVal DocToSearch As String, ByVal GetThis As String) As String
        Return System.Text.RegularExpressions.Regex.Match(DocToSearch, "<li><span>" & GetThis & "</span>(.*?)</li>", System.Text.RegularExpressions.RegexOptions.Multiline).Groups(1).Value
    End Function
Now to use that code you would do the following, im going to make your username appear in a message box:
Code: Select all
MsgBox(GetProfileInfo(WebBrowser1.DocumentText, "NAME"))
The first value in that code is "WebBrowser1.DocumentText" because that is where you will be reading the information from. The second part "NAME" is what information you want from the page. If you wanted to get the amount of credits you have you would use:
Code: Select all
GetProfileInfo(WebBrowser1.DocumentText, "CREDITS")
If you wanted to get your email address you would use:
Code: Select all
GetProfileInfo(WebBrowser1.DocumentText, "EMAIL")
To place it into a label or textbox or something just use it like:
Code: Select all
Label1.Text = GetProfileInfo(WebBrowser1.DocumentText, "NAME")
So thats a really quick way to do it with a small amount of code cooll;
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
MrAksel
C# Coder
C# Coder
Posts: 1758
Joined: Fri Mar 26, 2010 12:27 pm

Re: CnS Login & Account Info
MrAksel
WOW finally dude this is nice why didn't you think about this before???
It's fantastic!
It works fantastic!
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;


Over 30 projects with source code!
Please give reputation to helpful members!

Image
Image
User avatar
Codex
Coding God
Coding God
Posts: 2028
Joined: Wed Mar 31, 2010 5:50 pm

Re: CnS Login & Account Info
Codex
Hello

I had the first part done, the login part (if u can remember my "CodenStuff Login", but i never tried retrieving the credits and stuff about the account.

Thanks ;)
We shall let the revolution begin.. the revolution for freedom, freedom against censorship. We shall fight in the fields and in the streets, we shall fight in the hills; we shall never surrender
User avatar
Cheatmasterbw
Coding God
Coding God
Posts: 1506
Joined: Fri Jan 01, 2010 2:30 pm

Re: CnS Login & Account Info
Cheatmasterbw
is there a way to see if the username and/or the password is incorrect?
http://www.megaapps.tk/
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4389
Joined: Tue Aug 04, 2009 1:47 am

Re: CnS Login & Account Info
CodenStuff
Hello,

Hmm you could just check the page for the incorrect message. In the "WebBrowser1_DocumentCompleted" event put this code:
Code: Select all
If WebBrowser1.DocumentText.Contains("You have specified an incorrect") Then
            MsgBox("Login details incorrect please check and try again!")
        End If
If you enter a wrong username or password it will show the incorrect details page and that code just checks for the incorrect login message and shows a messagebox is its wrong but you could make a login form popup or something.
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
Cheatmasterbw
Coding God
Coding God
Posts: 1506
Joined: Fri Jan 01, 2010 2:30 pm

Re: CnS Login & Account Info
Cheatmasterbw
thanks!
http://www.megaapps.tk/
User avatar
Cheatmasterbw
Coding God
Coding God
Posts: 1506
Joined: Fri Jan 01, 2010 2:30 pm

Re: CnS Login & Account Info
Cheatmasterbw
how do i log out?
http://www.megaapps.tk/
Lewis
Coding God
Coding God
Posts: 1564
Joined: Sun Dec 20, 2009 2:12 pm

Re: CnS Login & Account Info
Lewis
ucp.php?mode=logout

And this is great, It will go well with my blogger app :P
Image
User avatar
Cheatmasterbw
Coding God
Coding God
Posts: 1506
Joined: Fri Jan 01, 2010 2:30 pm

Re: CnS Login & Account Info
Cheatmasterbw
i need the session id
http://www.megaapps.tk/
Lewis
Coding God
Coding God
Posts: 1564
Joined: Sun Dec 20, 2009 2:12 pm

Re: CnS Login & Account Info
Lewis
I dont know then :P
Image
12 posts Page 1 of 2
Return to “CnS SideBar”