Does any one knows how to use the WinHttpRequest to login facebook or gmail in VB.NET(2010 Version)?

Posted by ??? on Stack Overflow See other posts from Stack Overflow or by ???
Published on 2012-04-03T05:19:23Z Indexed on 2012/04/03 5:29 UTC
Read the original article Hit count: 297

Filed under:
|

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

© Stack Overflow or respective owner

Related posts about vb.net

Related posts about vb.net-2010