Now, I can download the webpage source code to the RichTextBox. But now I want to use the WinHttpRequest to login facebook or gmail,etc. I tried to do, but it didn't work!Any one can help me? Thnak you! This is my code:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
RichTextBox1.Text = winhttp("http://www.facebook.com")
End Sub
Function winhttp(ByVal URL As String) As String
Dim pass, email As String
pass = "my password"
email = "myemail"
Dim winHTTPReq : winHTTPReq = CreateObject("WinHttp.WinHttpRequest.5.1")
Dim objhttp As Object = CreateObject("WinHttp.WinHttpRequest.5.1")
Dim Data As String
objhttp.Open("POST", URL, False) ''method
objhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
objhttp.setRequestHeader("Referer", "your refresh url")
objhttp.send("email=" & email & "&pass=" & pass & "&perm_login=on")
objhttp.WaitForResponse()
Data = objhttp.responseText
Data = Replace(Data, " ", "")
Data = Replace(Data, vbTab, "")
Data = Replace(Data, vbCrLf, "")
Data = Replace(Data, " ", "")
Return Data
End Function
End Class