vb.net login help

Discussion in 'Code Snippets and Tutorials' started by chelsea1, Mar 21, 2007.

  1. chelsea1

    chelsea1 Level IV

    Joined:
    Nov 26, 2006
    Messages:
    2,538
    Likes Received:
    31
    Location:
    London
    well i studied mystical's wrapper for a bit but i need some help
    can someone tell me what the code is to login to neo if the gui looks like this
    [​IMG]
    +rep for whoever gives me the code and remember this is vb.net and NOT vb6 (otherwise i would have used the_skip's code)
     
  2. ricky92

    ricky92 Administrator
    Staff Member

    Joined:
    Nov 10, 2006
    Messages:
    1,866
    Likes Received:
    67
    In the wrapper there is a NeoLogin function, to use it write this code:
    Code (Text):
    1. Dim bLoggedIn As Boolean
    2. Wrapper.NeoLogin(txtUsername.Text, txtPassword.Text, bLoggedIn)
    3. If bLoggedIn = True Then MsgBox "Logged In!!!"
    Change txtUsername and txtPassword to whatever you want!!! ;)
     
  3. chelsea1

    chelsea1 Level IV

    Joined:
    Nov 26, 2006
    Messages:
    2,538
    Likes Received:
    31
    Location:
    London
    ok i still don't really understand ricky
    can you post the whole code which would be used (even the bits out of mystical's code)
     
  4. ricky92

    ricky92 Administrator
    Staff Member

    Joined:
    Nov 10, 2006
    Messages:
    1,866
    Likes Received:
    67
    ok, in a topic there is the new TCPWrapper by Mystical. The function you can use is this:
    Code (Text):
    1.     Public Function NeoLogin(ByVal user As String, ByVal pass As String, ByRef loggedIn As Boolean) As String
    2.         ClearCookies()
    3.         Dim strHTML As String = Nothing
    4.         Request("GET", "http://Filtered Link - For the safety of our users please do not post direct links to Neopets./loginpage.phtml", "http://google.com")
    5.         Pause(1)
    6.         Request("POST", "http://www.Filtered Link - For the safety of our users please do not post direct links to Neopets./hi.phtml?destination=%2Fpetcentral.phtml&username=" + user, "http://Filtered Link - For the safety of our users please do not post direct links to Neopets./loginpage.phtml")
    7.         Pause(1)
    8.         Request("POST", "http://www.Filtered Link - For the safety of our users please do not post direct links to Neopets./login.phtml?username=" + user + "&password=" + pass + "&destination=%2Fpetcentral.phtml", "http://Filtered Link - For the safety of our users please do not post direct links to Neopets./hi.phtml")
    9.         strHTML = Request("GET", "http://www.Filtered Link - For the safety of our users please do not post direct links to Neopets./objects.phtml", "http://www.Filtered Link - For the safety of our users please do not post direct links to Neopets./petcentral.phtml")
    10.         If strHTML.Contains("Welcome,") Then
    11.             loggedIn = True
    12.             Return "Logged In"
    13.         Else
    14.             If strHTML.Contains("too many times") Then
    15.                 loggedIn = False
    16.                 Return "To Many Login Attempts"
    17.             Else
    18.                 If strHTML.Contains("not logged in") Then
    19.                     loggedIn = False
    20.                     Return "Wrong Password"
    21.                 Else
    22.                     If strHTML.Contains("frozen") Then
    23.                         loggedIn = False
    24.                         Return "Account Frozen"
    25.                     Else
    26.                         If strHTML.Contains("just a technical problem") Then
    27.                             loggedIn = False
    28.                             Return "Neopets is down for maintenance."
    29.                         Else
    30.                             loggedIn = False
    31.                             Return strHTML
    32.                         End If
    33.                     End If
    34.                 End If
    35.             End If
    36.         End If
    37.     End Function
    But it's already in the wrapper's code, so you just need to call it. What's the name of the wrapper? If it's TCPWrapper, then you can use this code (with the textboxes called txtUsername and txtPassword):
    Code (Text):
    1. Dim bLogin As Boolean
    2. TCPWrapper.NeoLogin(txtUsername.Text, txtPassword.Text, bLogin)
    3. If bLogin = True Then
    4. MsgBox("Logged in!!!")
    5. 'code here
    6. End If
    What it does is just posting the login link. If the login is successful, the bLogin value will be "True", if not, it will be "False".

    PS: Remember to change all the filtered links in the wrapper code, or it won't work!!!
     
  5. chelsea1

    chelsea1 Level IV

    Joined:
    Nov 26, 2006
    Messages:
    2,538
    Likes Received:
    31
    Location:
    London
    i have this
    Code (Text):
    1. Public Class Form1
    2.     Public Function NeoLogin(ByVal user As String, ByVal pass As String, ByRef loggedIn As Boolean) As String
    3.         ClearCookies()
    4.         Dim strHTML As String = Nothing
    5.         Request("GET", "http://www.Neopets./loginpage.phtml", "http://google.com")
    6.         Pause(1)
    7.         Request("POST", "http://www.www.Neopets./hi.phtml?destination=%2Fpetcentral.phtml&username=" + user, "http://www.Neopets./loginpage.phtml")
    8.         Pause(1)
    9.         Request("POST", "http://www.Neopets./login.phtml?username=" + user + "&password=" + pass + "&destination=%2Fpetcentral.phtml", "http://www.Neopets./hi.phtml")
    10.         strHTML = Request("GET", "http://www.Neopets./objects.phtml", "http://www.www.Neopets./petcentral.phtml")
    11.         If strHTML.Contains("Welcome,") Then
    12.             loggedIn = True
    13.             Return "Logged In"
    14.         Else
    15.             If strHTML.Contains("too many times") Then
    16.                 loggedIn = False
    17.                 Return "To Many Login Attempts"
    18.             Else
    19.                 If strHTML.Contains("not logged in") Then
    20.                     loggedIn = False
    21.                     Return "Wrong Password"
    22.                 Else
    23.                     If strHTML.Contains("frozen") Then
    24.                         loggedIn = False
    25.                         Return "Account Frozen"
    26.                     Else
    27.                         If strHTML.Contains("just a technical problem") Then
    28.                             loggedIn = False
    29.                             Return "Neopets is down for maintenance."
    30.                         Else
    31.                             loggedIn = False
    32.                             Return strHTML
    33.                         End If
    34.                     End If
    35.                 End If
    36.             End If
    37.         End If
    38.     End Function
    39.  
    40.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    41.         Dim bLoggedIn As Boolean
    42.         Dim txtusername As String
    43.         Dim txtPassword As String
    44.  
    45.         txtusername = TextBox1.Text
    46.         txtPassword = TextBox2.Text
    47.  
    48.         Wrapper.NeoLogin(txtusername, txtPassword, bLoggedIn)
    49.         If bLoggedIn = True Then MsgBox("Logged In!!!")
    50.     End Sub
    51. End Class
    but in the debug box it says this,
    where should i declair them?
     
  6. ricky92

    ricky92 Administrator
    Staff Member

    Joined:
    Nov 10, 2006
    Messages:
    1,866
    Likes Received:
    67
    No, you don't need to create a new class, just use the wrapper code you can find here
    The NeoLogin function is already there.
     
  7. the_skip

    the_skip Level IV

    Joined:
    Dec 25, 2006
    Messages:
    2,354
    Likes Received:
    1
    Location:
    Indiana
    it needs to be a wrapper class not form class. And that gui is from what I made.
     
  8. chelsea1

    chelsea1 Level IV

    Joined:
    Nov 26, 2006
    Messages:
    2,538
    Likes Received:
    31
    Location:
    London
    sorry i forgot to ask but that is the basic idea
    two textboxxes and a login button
    if you mind i will remove...?
     
  9. the_skip

    the_skip Level IV

    Joined:
    Dec 25, 2006
    Messages:
    2,354
    Likes Received:
    1
    Location:
    Indiana
    no I don't. Anything I will post in my tutorails you can use here but shall not be redistributed.
     
  10. expon

    expon Administrator
    Staff Member

    Joined:
    Oct 30, 2006
    Messages:
    1,393
    Likes Received:
    56
    Location:
    UK
    get it figured out if not I can make a tutorial.