can someone explain better ho thats done. I'm a bit confused on it. i've been rading up on guides on VB.NET, and iknow how POST and GET variables work, but i can't seem to figure out y the rest help will get you +rep i'm also kind of cconfused on how you control another class to come up after the login, or is the login spose to be a popup? thanks if you help sorry if i sound noobish.
Re: using Mysticals Wrapper to set up a login? I was about to get back to you cause I was lacking a bit of time earlier here's the wrapper I'm using... it's mystical one. I know I changed some lines for my needs but I can't remember witch one. There's also a getbetween function in there. It's a class so don't put it IN you form class. Code (Text): Public Class TCPWrapper Inherits System.Windows.Forms.UserControl #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'UserControl overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() components = New System.ComponentModel.Container End Sub #End Region Private colCookies As New Collection Dim strCookies As String Public LastPage As String Public Function Request(ByVal Method As String, ByVal URL As String, ByVal Referer As String) As String Dim Host As String = Nothing Dim strFile As String = Nothing Dim strPost As String = Nothing Dim pos As Integer = 0 If Referer Is Nothing Then Referer = LastPage End If If URL.Contains("http://") Then Host = URL.Substring(7) Else Host = URL End If If Host.Contains("/") Then pos = Host.IndexOf("/", 0) strFile = Host.Substring(pos) Host = Host.Substring(0, pos) Else strFile = "/" End If If Method = "POST" Then pos = strFile.IndexOf("?") If Not (pos = -1) Then strPost = strFile.Substring(pos + 1) strFile = strFile.Substring(0, pos) Else strPost = Nothing End If End If If Method = "POST2" Then pos = strFile.IndexOf("?") If Not (pos = -1) Then strPost = strFile.Substring(pos + 1) strFile = strFile.Substring(0, pos) Else strPost = "" End If End If LastPage = URL Dim ReqHeaders As String = Nothing If Method = "GET" OrElse Method = "PIC" Then ReqHeaders = "GET" + " " + strFile + " HTTP/1.1" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Host: " + Host + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.8.0.7) Gecko/20060909 Firefox/1.5.0.7" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Accept-Language: en-us,en;q=0.5" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Accept-Encoding: gzip, deflate" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Keep-Alive: 300" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Connection: keep-alive" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Referer: " + Referer + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Cookie: " + strCookies + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" Else ReqHeaders = "POST " + strFile + " HTTP/1.1" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Host: " + Host + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.8.0.7) Gecko/20060909 Firefox/1.5.0.7" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Accept-Language: en-us,en;q=0.5" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Accept-Encoding: gzip, deflate" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Keep-Alive: 300" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Connection: keep-alive" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Referer: " + Referer + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Cookie: " + strCookies + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Content-Type: application/x-www-form-urlencoded" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Content-Length: " + strPost.Length.ToString + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Connection: close" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + strPost End If If Method = "PIC" Then ReqHeaders.Replace("Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5", "Accept: image/png,*/*;q=0.5") End If Dim tcp As New System.Net.Sockets.TcpClient Dim netstream As System.Net.Sockets.NetworkStream Dim TN(1) As Long If Referer = "" Then Referer = LastPage If InStr(1, URL, "http://") <> 0 Then Host = Mid$(URL, 8) If InStr(1, Host, "/") <> 0 Then Host = Mid$(Host, 1, InStr(1, Host, "/") - 1) If InStr(1, Host, "?") <> 0 Then Host = Mid$(Host, 1, InStr(1, Host, "?") - 1) LastPage = URL Try tcp.Connect(Host, 80) Catch ex As Exception Return ex.Message End Try Dim sendbytes As Byte() sendbytes = System.Text.Encoding.ASCII.GetBytes(ReqHeaders) netstream = tcp.GetStream() netstream.Write(sendbytes, 0, sendbytes.Length) Dim sr As StreamReader = New StreamReader(netstream, Encoding.Default) Dim strHTML As String = sr.ReadToEnd Dim strParts As String() = Regex.Split(strHTML, Environment.NewLine + Environment.NewLine) strCookies = ParseCookies(strParts(0)) If strParts(0).Contains("Content-Encoding") Then strParts(1) = DecompressGzip(strParts(1)) End If Return strParts(0) + Environment.NewLine + Environment.NewLine + strParts(1) End Function Public Function DecompressGzip(ByVal compressed As String) As String Dim memStream As MemoryStream = New MemoryStream(System.Text.Encoding.Default.GetBytes(compressed)) Dim decompressStream As GZipStream = New GZipStream(memStream, CompressionMode.Decompress) Dim endBytes(4) As Byte Dim position As Integer = CType(memStream.Length, Integer) - 4 memStream.Position = position memStream.Read(endBytes, 0, 4) memStream.Position = 0 Dim buffer(BitConverter.ToInt32(endBytes, 0) + 100) As Byte Dim offset As Integer = 0 Dim total As Integer = 0 While True Dim bytesRead As Integer = decompressStream.Read(buffer, offset, 100) If bytesRead = 0 Then Exit While End If offset += bytesRead total += bytesRead End While Return Encoding.ASCII.GetString(buffer) End Function Public Function ParseCookies(ByVal Headers As String) As String ParseCookies = "" Dim reg As Regex Dim matches As MatchCollection Dim match As Match reg = New Regex("set-cookie:\s*([^=]+)=([^;]+);", RegexOptions.IgnoreCase) If reg.IsMatch(Headers) Then matches = reg.Matches(Headers) For Each match In matches Try colCookies.Add(match.Groups(1).ToString & "=" & match.Groups(2).ToString, match.Groups(1).ToString) Catch ex As Exception colCookies.Remove(match.Groups(1).ToString) colCookies.Add(match.Groups(1).ToString & "=" & match.Groups(2).ToString, match.Groups(1).ToString) End Try Next End If Dim i As Long For i = 1 To colCookies.Count Step 1 ParseCookies = ParseCookies & colCookies.Item(i).ToString & ";" Next End Function Public Function StripHeaders(ByVal strSource As String) As String Dim strParts() As String = Regex.Split(strSource, Environment.NewLine + Environment.NewLine) Return strParts(1) End Function Public Function NeoLogin(ByVal user As String, ByVal pass As String, ByRef loggedIn As Boolean) As String Dim strHTML As String = Nothing Request("GET", "http://www.neopets.com/loginpage.phtml", "http://www.google.com") Pause(1) Request("POST", "http://www.neopets.com/hi.phtml?destination=%2Findex.phtml&username=" + user, "http://www.neopets.com/loginpage.phtml") Pause(1) strHTML = Request("POST", "http://www.neopets.com/login.phtml?username=" + user + "&password=" + pass + "&destination=%2Findex.phtml", "http://www.neopets.com/hi.phtml") If strHTML.Contains("Set-Cookie: neologin=") Then loggedIn = True Return "Logged In" Else If strHTML.Contains("too many times") Then loggedIn = False Return "To Many Login Attempts" Else If strHTML.Contains("badpassword") Then loggedIn = False Return "Wrong Username/Password" Else If strHTML.Contains("frozen") Then loggedIn = False Return "Account Frozen" Else If strHTML.Contains("just a technical problem") Then loggedIn = False Return "Neopets is down for maintenance" Else loggedIn = False Return "Unknow Error" End If End If End If End If End If End Function Private Shared Sub Pause(ByVal seconds As Double) Dim num As Double = seconds * 1000 Dim t1 As DateTime = DateTime.Now Dim t2 As DateTime = DateTime.Now Dim tmDiff As TimeSpan = t2 - t1 While Convert.ToDouble(tmDiff.TotalMilliseconds.ToString) < num t2 = DateTime.Now tmDiff = t2 - t1 Application.DoEvents() End While End Sub Public Function GrabPic(ByVal strURL As String) As System.Drawing.Image Dim memStream As New MemoryStream(System.Text.Encoding.Default.GetBytes(StripHeaders(Request("GET", strURL, LastPage)))) GrabPic = Image.FromStream(memStream) Return GrabPic End Function Public Sub ClearCookies() colCookies.Clear() strCookies = Nothing End Sub Public Function GetBetween(ByVal Source As String, ByVal Start As String, ByVal Finish As String) As String Dim Result = "" Dim A = InStr(1, Source, Start) + Len(Start) If A = 0 Then Result = "" Return Result Else Dim B = InStr(A, Source, Finish) If B = 0 Then Result = "" Return Result Else Result = Mid(Source, A, B - A) Return Result End If End If End Function End Class You'll also need to declare this at the very beginning (before your form class) Code (Text): Imports System.Text.Regularexpressions Imports System.Net Imports System.IO Imports System.Text Imports System.IO.Compression Imports System.Runtime.Serialization.Formatters.Binary Finally, you need to declare a new Wrapper variable: Code (Text): Private Wrapper As New TCPWrapper The login function (already incorporated in the wrapper class) Code (Text): Dim Response = Wrapper.NeoLogin(txtUser.Text, txtPass.Text, False) If everything is fine, you'll receive "Logged In". If there was a problem during login, the "response" variable will contain the reason. Code (Text): If Response = "Logged In" Then Now, to use those "get" and "post" function. There's two ways of using the get. With a referer or without. If you don't specify one, the program wrapper class will take care of it. Code (Text): Wrapper.Request("GET", "http://www.neopets.com/quickref.phtml", "") Wrapper.Request("GET", "http://www.neopets.com/pound/", "http://www.neopets.com/quickref.phtml") And finally, the post command. Code (Text): Wrapper.Request("POST", "http://www.neopets.com/pound/process_adopt.phtml?pet_name=" + txtPetName.Text, "http://www.neopets.com/pound/adopt.phtml?search=" + txtPetName.Text) In all those cases, if you do a "get" or "post" and want to analyze the information returned, you need to put them in a variable. Code (Text): Response = Wrapper.request(blahblahblahblah) Now, +rep me a thousand times
Re: using Mysticals Wrapper to set up a login? um... now getting the authorization sysrem getting worked in is causing problems... i've been playing with it all day, but idk what i'm doing wrong. heres the file:
Re: using Mysticals Wrapper to set up a login? oops, it will never work... I changed something in the wrapper for my needs and it screw up the login part... take this wrapper instead (same thing but unmodified) Code (Text): Public Class TCPWrapperAuth Inherits System.Windows.Forms.UserControl #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'UserControl overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() components = New System.ComponentModel.Container End Sub #End Region Private colCookies As New Collection Dim strCookies As String Public LastPage As String Public bGzip As Boolean Public Function Request(ByVal Method As String, ByVal URL As String, ByVal Referer As String) As String Dim Host As String = Nothing Dim strFile As String = Nothing Dim strPost As String = Nothing Dim pos As Integer = 0 If Referer Is Nothing Then Referer = LastPage End If If URL.Contains("http://") Then Host = URL.Substring(7) Else Host = URL End If If Host.Contains("/") Then pos = Host.IndexOf("/", 0) strFile = Host.Substring(pos) Host = Host.Substring(0, pos) Else strFile = "/" End If If Method = "POST" Then pos = strFile.IndexOf("?") If Not (pos = -1) Then strPost = strFile.Substring(pos + 1) strFile = strFile.Substring(0, pos) Else strPost = Nothing End If End If LastPage = URL Dim ReqHeaders As String = Nothing If bGzip = True Then If Method = "GET" OrElse Method = "PIC" Then ReqHeaders = "GET" + " " + strFile + " HTTP/1.1" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Host: " + Host + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.8.0.7) Gecko/20060909 Firefox/1.5.0.7" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Accept-Language: en-us,en;q=0.5" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Accept-Encoding: gzip, deflate" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Keep-Alive: 300" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Connection: keep-alive" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Referer: " + Referer + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Cookie: " + strCookies + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" Else ReqHeaders = "POST " + strFile + " HTTP/1.1" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Host: " + Host + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.8.0.7) Gecko/20060909 Firefox/1.5.0.7" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Accept-Language: en-us,en;q=0.5" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Accept-Encoding: gzip, deflate" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Keep-Alive: 300" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Connection: keep-alive" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Referer: " + Referer + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Cookie: " + strCookies + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Content-Type: application/x-www-form-urlencoded" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Content-Length: " + strPost.Length.ToString + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Connection: close" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + strPost End If If Method = "PIC" Then ReqHeaders.Replace("Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5", "Accept: image/png,*/*;q=0.5") End If Else If Method = "GET" OrElse Method = "PIC" Then ReqHeaders = "GET" + " " + strFile + " HTTP/1.1" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Host: " + Host + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.8.0.7) Gecko/20060909 Firefox/1.5.0.7" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Accept-Language: en-us,en;q=0.5" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" & "" + "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Keep-Alive: 300" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Connection: keep-alive" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Referer: " + Referer + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Cookie: " + strCookies + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" Else ReqHeaders = "POST " + strFile + " HTTP/1.1" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Host: " + Host + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.8.0.7) Gecko/20060909 Firefox/1.5.0.7" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Accept-Language: en-us,en;q=0.5" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Keep-Alive: 300" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Connection: keep-alive" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Referer: " + Referer + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Cookie: " + strCookies + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Content-Type: application/x-www-form-urlencoded" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Content-Length: " + strPost.Length.ToString + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "Connection: close" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + "" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + strPost End If If Method = "PIC" Then ReqHeaders.Replace("Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5", "Accept: image/png,*/*;q=0.5") End If End If Dim tcp As New System.Net.Sockets.TcpClient Dim netstream As System.Net.Sockets.NetworkStream Dim TN(1) As Long If Referer = "" Then Referer = LastPage If InStr(1, URL, "http://") <> 0 Then Host = Mid$(URL, 8) If InStr(1, Host, "/") <> 0 Then Host = Mid$(Host, 1, InStr(1, Host, "/") - 1) If InStr(1, Host, "?") <> 0 Then Host = Mid$(Host, 1, InStr(1, Host, "?") - 1) If Mid$(Host, 1, 4) = "www." Then Host = Mid$(Host, 5) LastPage = URL Try tcp.Connect(Host, 80) Catch ex As Exception Return ex.Message End Try Dim sendbytes As Byte() sendbytes = System.Text.Encoding.ASCII.GetBytes(ReqHeaders) netstream = tcp.GetStream() netstream.Write(sendbytes, 0, sendbytes.Length) Dim sr As StreamReader = New StreamReader(netstream, Encoding.Default) Dim strHTML As String = sr.ReadToEnd Dim strParts As String() = Regex.Split(strHTML, Environment.NewLine + Environment.NewLine) strCookies = ParseCookies(strParts(0)) If strParts(0).Contains("Content-Encoding") Then strParts(1) = DecompressGzip(strParts(1)) End If Return strParts(1) End Function Public Function DecompressGzip(ByVal compressed As String) As String Dim memStream As MemoryStream = New MemoryStream(System.Text.Encoding.Default.GetBytes(compressed)) Dim decompressStream As GZipStream = New GZipStream(memStream, CompressionMode.Decompress) Dim endBytes(4) As Byte Dim position As Integer = CType(memStream.Length, Integer) - 4 memStream.Position = position memStream.Read(endBytes, 0, 4) memStream.Position = 0 Dim buffer(BitConverter.ToInt32(endBytes, 0) + 100) As Byte Dim offset As Integer = 0 Dim total As Integer = 0 While True Dim bytesRead As Integer = decompressStream.Read(buffer, offset, 100) If bytesRead = 0 Then Exit While End If offset += bytesRead total += bytesRead End While Return Encoding.ASCII.GetString(buffer) End Function Public Function ParseCookies(ByVal Headers As String) As String ParseCookies = "" Dim reg As Regex Dim matches As MatchCollection Dim match As Match reg = New Regex("set-cookie:\s*([^=]+)=([^;]+);", RegexOptions.IgnoreCase) If reg.IsMatch(Headers) Then matches = reg.Matches(Headers) For Each match In matches Try colCookies.Add(match.Groups(1).ToString & "=" & match.Groups(2).ToString, match.Groups(1).ToString) Catch ex As Exception colCookies.Remove(match.Groups(1).ToString) colCookies.Add(match.Groups(1).ToString & "=" & match.Groups(2).ToString, match.Groups(1).ToString) End Try Next End If Dim i As Long For i = 1 To colCookies.Count Step 1 ParseCookies = ParseCookies & colCookies.Item(i).ToString & ";" Next End Function Public Function StripHeaders(ByVal strSource As String) As String Dim strParts() As String = Regex.Split(strSource, Environment.NewLine + Environment.NewLine) Return strParts(1) End Function Private Shared Sub Pause(ByVal seconds As Double) Dim num As Double = seconds * 1000 Dim t1 As DateTime = DateTime.Now Dim t2 As DateTime = DateTime.Now Dim tmDiff As TimeSpan = t2 - t1 While Convert.ToDouble(tmDiff.TotalMilliseconds.ToString) < num t2 = DateTime.Now tmDiff = t2 - t1 Application.DoEvents() End While End Sub Public Function GrabPic(ByVal strURL As String) As System.Drawing.Image Dim memStream As New MemoryStream(System.Text.Encoding.Default.GetBytes(StripHeaders(Request("GET", strURL, LastPage)))) GrabPic = Image.FromStream(memStream) Return GrabPic End Function Public Function DownloadImage(ByVal URL As String) As System.Drawing.Image Dim imageFile As New WebClient Dim bytes() As Byte = imageFile.DownloadData(URL) Dim imageStream As New MemoryStream(bytes) Dim downloadedImage As System.Drawing.Image = Image.FromStream(imageStream) DownloadImage = downloadedImage End Function Public Sub ClearCookies() colCookies.Clear() strCookies = Nothing End Sub End Class
Error 1 'NeofriendsLogin' is not a member of 'WindowsApplication1.TCPWrapperAuth'. C:\Documents and Settings\Owner\My Documents\WindowsApplication1\WindowsApplication1\Form1.vb 51 24 WindowsApplication1
sure you're aint using the nf auth system for vb6 And the auth system you can find on the forum here need some work to work.
i'm using the one that expon posted... i forgot to add it, and when i aded the NeoFriendsLogin function with the auth code expon posted in it, 6 errors came up Error 1 'lblStatus2' is not a member of 'WindowsApplication1.TCPWrapperAuth'. Error 2 Name 'txtNFUser' is not declared. Error 3 Name 'txtNFPass' is not declared. Error 4 'lblStatus2' is not a member of 'WindowsApplication1.TCPWrapperAuth'. Error 5 'lblStatus2' is not a member of 'WindowsApplication1.TCPWrapperAuth'. Error 6 'lblStatus2' is not a member of 'WindowsApplication1.TCPWrapperAuth'.
seriously, take your time... starting with vb.net and wanting to code a program using inet control seems to be way above what you can do for the moment. If you can't understand how to use an external class within your main one, you're screwed. Maybe you wanted a bit to much at the same time. The error in your last post are pretty basic one, so that lead me to the fact that it may very well be the first time you use vb. Start simple, using program without class, playing with the GUI, properties of each control, then start implementing class, simple one, to see how they work. Unfortunately, I don't have any website or book for this, for search around, there's plenty of them. I don't want to demotivate you, far from it. Just don't try to skip a step in the learning process. edit: like I stated previously, the auth system posted by expon here won't work out of the box. Work need to be done on it.
When you posted your *fixed* version of Mysticals Wrapper, you forgot the NeoLogin function. Just add it back in between Pause and GrabPic. That fixes those errors you were getting. MODS: Sorry for the gravedig, but I was learning how to use wrappers and I was using this, and having it miss that slightly vital code screwed me and I spent over an hour searching. Saving others the trouble. Sorry again. Code (Text): Public Function NeoLogin(ByVal user As String, ByVal pass As String, ByRef loggedIn As Boolean) As String Dim strHTML As String = Nothing Request("GET", "http://www.neopets.com/loginpage.phtml", "http://www.google.com") Pause(1) Request("POST", "http://www.neopets.com/hi.phtml?destination=%2Findex.phtml&username=" + user, "http://www.neopets.com/loginpage.phtml") Pause(1) strHTML = Request("POST", "http://www.neopets.com/login.phtml?username=" + user + "&password=" + pass + "&destination=%2Findex.phtml", "http://www.neopets.com/hi.phtml") If strHTML.Contains("Set-Cookie: neologin=") Then loggedIn = True Return "Logged In" Else If strHTML.Contains("too many times") Then loggedIn = False Return "To Many Login Attempts" Else If strHTML.Contains("badpassword") Then loggedIn = False Return "Wrong Username/Password" Else If strHTML.Contains("frozen") Then loggedIn = False Return "Account Frozen" Else If strHTML.Contains("just a technical problem") Then loggedIn = False Return "Neopets is down for maintenance" Else loggedIn = False Return "Unknow Error" End If End If End If End If End If End Function Edit: Aww crap, even after all that, now I get an 'Unknown Error' from the login code. Does anyone have an updated wrapper?!
Here's the complete wrapper with a simple login form - fully functionnal. Just unzip the file and open the solution. Dunno what was your error but I know that all the information posted here is correct.