954,514 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

C# - Check FaceBook Notifications Using WebBrowser

So basically I want to login to FaceBook and check if I have any notifications.

I haven't a clue how to check if I have notifications and I'm not very good at all with HTML so I'm not sure what I'm looking for in the page source to grab the notification info. So if anyone is able to show me how I'll be very happy.

Any help with this issue is appreciated :)

P.S. The reason I'm doing this is because I have a Velleman circuit (similar to Arduino) that connects to the computer via USB and I can control it with programs I've made in C#. I'm going to make it light up certain LED's depending on notifications I have on my profile, I just have to work out how to get that information first then I'm away :)

This is how I'm logging in, and it works completely fine.

bool loggedOn = false;

        private void frm_Main_Load(object sender, EventArgs e)
        {
            web_FBCheck.Navigate("https://login.facebook.com/login.php?login_attempt=1");
        }

        private void web_FBCheck_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            if (!loggedOn)
            {
                HtmlElement emailElement = web_FBCheck.Document.GetElementById("email");
                HtmlElement passwordElement = web_FBCheck.Document.GetElementById("pass");
                HtmlElement loginButtonElement = web_FBCheck.Document.GetElementById("Login");

                if (emailElement != null)
                {
                    emailElement.InnerText = "username@hotmail.com";
                }

                if (passwordElement != null)
                {
                    passwordElement.InnerText = "password";
                }

                if (loginButtonElement != null)
                {
                    loginButtonElement.InvokeMember("click");
                }
            }
        }
The Road To Voi
Newbie Poster
3 posts since Nov 2010
Reputation Points: 10
Solved Threads: 0
 

I worked it out, marking as solved.

The Road To Voi
Newbie Poster
3 posts since Nov 2010
Reputation Points: 10
Solved Threads: 0
 

How'd you fix it, just for posterity?

alc6379
Cookie... That's it
Team Colleague
2,820 posts since Dec 2003
Reputation Points: 186
Solved Threads: 147
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: