Facebook Logout and Like

早过忘川 提交于 2019-12-25 01:56:21

问题


I am new to VB.net and making a facebook windows app. I am doing just few simple things like login, log out and like a page. I was able to login in FB by using help from http://social.msdn.microsoft.com/Forums/en/vbgeneral/thread/94a8ce89-2318-4b14-9915-58f95ce58485

But now am stuck at log out and liking a page. I am using m.facebook.com so to keep my coding easy understandable and convenient.

Please tell me how to log out and like a page.

facebook uses a logout key that i am unable to extract from the page. And like is also creating some problem as there is no ID, so i cant use getelementbyid

thanks for help


回答1:


If someone is facing the same problem, here is the solution:

Facebook Logout:

Dim allelements As HtmlElementCollection = WebBrowser1.Document.All

    For Each webpageelement As HtmlElement In allelements

        If webpageelement.GetAttribute("data-sigil") = "logout" Then

            WebBrowser1.Navigate(webpageelement.GetAttribute("href"))

        End If

    Next

Facebook Page Like:

 Dim allelements As HtmlElementCollection = WebBrowser1.Document.All

    For Each webpageelement As HtmlElement In allelements

        If webpageelement.GetAttribute("value") = "Like" Then

            webpageelement.InvokeMember("click")                

        End If
    Next


来源:https://stackoverflow.com/questions/6989042/facebook-logout-and-like

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!