问题
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