Results 1 to 8 of 8

Thread: Help on Facebook Login in VB2008

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2009
    Posts
    4

    Help on Facebook Login in VB2008

    Hello guys, i am now to this forum and i hope i can learn much about vb here =].
    The problem i am stating today is that i want this program to log in to
    facebook (https://login.facebook.com/login.php?login_attempt=1)
    and after that, go to
    mousehunt (http://apps.facebook.com/mousehunt/)
    to retrieve information from my account.

    So far, i've managed to make the application to login to my facebook account but i cannot make it navigate to mousehunt but even if i do so, my account will not be logged in please help.

    My code is the following,
    vb.net Code:
    1. Public Class Form1
    2.  
    3.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    4.        
    5.       Me.WebBrowser1.Document.GetElementById("email").SetAttribute("value", TextBox1.Text)
    6.         WebBrowser1.Document.GetElementById("pass").SetAttribute("value", TextBox2.Text)
    7.         WebBrowser1.Document.GetElementById("Login").InvokeMember("click")
    8.  
    9.     End Sub
    10.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    11.         WebBrowser1.Visible = True
    12.  
    13.     End Sub
    14.   Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    15.         WebBrowser1.ScriptErrorsSuppressed = True
    16.     End Sub
    17.  
    18.   End Class
    Last edited by Hack; Oct 21st, 2009 at 08:24 AM. Reason: Added Highlight Tags

  2. #2
    Addicted Member
    Join Date
    Oct 2009
    Posts
    212

    Re: Help on Facebook Login in VB2008

    Parts of the code seem to be missing. Where is the WebBrowser1.Navigate? You're going to need to call WebBrowser1.Navigate("http%3A%2F%2Fapps.facebook.com%2Fmousehunt%2F") after your login logic.

    Hope This Helps.

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2009
    Posts
    4

    Re: Help on Facebook Login in VB2008

    can you give me the code for it please ive tried just webbrowser1.navigate("www.apps.facebook/mousehunt")
    but it does not log me in when it load pls help

  4. #4
    Addicted Member
    Join Date
    Oct 2009
    Posts
    212

    Re: Help on Facebook Login in VB2008

    Good Luck, it would appear you're just starting out here, and quite frankly web automation isnt the easiest thing to learn vb on..

    Code:
            Me.WebBrowser1.Document.GetElementById("email").SetAttribute("value", TextBox1.Text)
    
            WebBrowser1.Document.GetElementById("pass").SetAttribute("value", TextBox2.Text)
    
            WebBrowser1.Document.GetElementById("Login").InvokeMember("click")
            WebBrowser1.Navigate("http://apps.facebook.com/mousehunt/")
    Some things to remember... If the document isnt fully loaded in the webbrowser this code will fail, you might want to investigate the DocumentCompleted event
    example:
    Code:
        Private Sub WebBrowser2_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser2.DocumentCompleted
            'do work here
        End Sub

  5. #5

    Thread Starter
    New Member
    Join Date
    Oct 2009
    Posts
    4

    Re: Help on Facebook Login in VB2008

    how do you know if your logged into facebook already?

  6. #6
    Addicted Member
    Join Date
    Oct 2009
    Posts
    212

    Re: Help on Facebook Login in VB2008

    Well how does a user know if he/she is logged into facebook? You're probably going to need to "test" for it somehow, probably in the documentcompleted event. Take a look at this post, it might help you figure out how to do it. http://www.vbforums.com/showthread.p...ebbrowser+html

  7. #7

    Thread Starter
    New Member
    Join Date
    Oct 2009
    Posts
    4

    Re: Help on Facebook Login in VB2008

    Sorry but i do not understand what the people are saying in the link ive tried to looping method but ive gotten an error when i run the application

  8. #8
    New Member
    Join Date
    May 2011
    Location
    india
    Posts
    2

    Re: Help on Facebook Login in VB2008

    HI,

    while using the webbrowser the application will be slow why dont u try this code.

    use the cookies and get response from website to login

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width