This is a VB.net 2, VS 2005 class for logging on to 6 facebook accounts and then browsing to various pages on a timer.
The purpose of this code is to appear that you have logged into facebook with your multiple accounts and then logged into the various programs to maximise your presence in that application. This is useful in some facebook applications because your application profile is raised to active status and appears first in various lists.
If you are to implement this code as is then you will need a form with a tab control with 6 tabs with a webbrowser on each. 3 buttons, one checkbox and a final webbrowser hidden somewhere (not visible).
I have not provide the project for download because I don’t have the time to remove all the personal information from it. Any questions please ask.
Imports System.Threading Imports System.Net Imports System.Web Imports System.Text Imports System.IO Public Class Form1 Public Enum AccountNumbers 'Replace Account 1-6 with usefulname here Account1 = 0 Account2 = 1 Account3 = 2 Account4 = 3 Account5 = 4 Account6 = 5 End Enum Private Structure AccountDetails Public Account As AccountNumbers Public Browser As WebBrowser Public Init As String Public Email As String Public Password As String Public Logoff As String End Structure Private Busy As Boolean Private CurrentLogin As AccountNumbers Private Details As New Collection Private CurrentTab As Integer Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.Timer1.Interval = 1000 * 60 * 10 'Replace "1234567890abcdef1234567890abcdef" and "1234567890abcdef1234567890abcdef" with Longon and logoff IDs, Email1-6 with email addresses and password 1-6 with passwords Call AddAccount(AccountNumbers.Account1 , Me.WebBrowser1, "1234567890abcdef1234567890abcdef", "email1", "password1", "1234567890abcdef1234567890abcdef") Call AddAccount(AccountNumbers.Account2 , Me.WebBrowser2, "1234567890abcdef1234567890abcdef", "email2", "password2", "1234567890abcdef1234567890abcdef") Call AddAccount(AccountNumbers.Account3 , Me.WebBrowser3, "1234567890abcdef1234567890abcdef", "email3", "password3", "1234567890abcdef1234567890abcdef") Call AddAccount(AccountNumbers.Account4 , Me.WebBrowser4, "1234567890abcdef1234567890abcdef", "email4", "password4", "1234567890abcdef1234567890abcdef") Call AddAccount(AccountNumbers.Account5 , Me.WebBrowser5, "1234567890abcdef1234567890abcdef", "email5", "password5", "1234567890abcdef1234567890abcdef") Call AddAccount(AccountNumbers.Account6 , Me.WebBrowser6, "1234567890abcdef1234567890abcdef", "email6", "password6", "1234567890abcdef1234567890abcdef") End Sub Private Sub AddAccount(ByVal AccountNumber As AccountNumbers, ByVal Browser As WebBrowser, ByVal Init As String, ByVal Email As String, ByVal Password As String, ByVal LogOff As String) Dim Account As New AccountDetails With Account .Account = AccountNumber .Browser = Browser .Init = Init .Email = Email .Password = Password .Logoff = LogOff End With Details.Add(Account) End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Busy = True Call DoUpdates() Busy = False End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Me.Timer1.Enabled = True End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Busy = True Call Me.Logoffall() Call Me.DoUpdates() Busy = False End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Me.Timer1.Enabled = False End Sub Private Sub DoUpdates() Dim Account As New AccountDetails For Each Account In Details Call Login(Account) Call LoadPages(Account) Next End Sub Private Sub Login(ByRef Account As AccountDetails) Dim PostDataStr As String = "challenge=" & Account.Init & " &md5pass=1&noerror=1&email=" & Account.Email & "&pass=" & Account.Password & "&persistent=1&doquicklogin=false" Dim PostDataByte() As Byte = Encoding.UTF8.GetBytes(PostDataStr) Dim AdditionalHeaders As String = "Content-Type: application/x-www-form-urlencoded" + Environment.NewLine Call Account.Browser.Navigate("https://login.facebook.com/login.php", "", PostDataByte, AdditionalHeaders) Dim Start As Date = Date.Now Do While Account.Browser.ReadyState <> WebBrowserReadyState.Complete Application.DoEvents() If SanityCheck(Start) Then Call Account.Browser.Refresh() Loop End Sub Private Sub LoadPages(ByRef Account As AccountDetails) 'A list of pages that you want to be refreshed and finally logout Call WaitForBrowser(Account.Browser, "http://apps.facebook.com/hottiesforsale/index.php") Call WaitForBrowser(Account.Browser, "http://apps.facebook.com/friendsforsale?s=sidenav") Call WaitForBrowser(Account.Browser, "http://apps.facebook.com/humangifts/") Call WaitForBrowser(Me.WebBrowser7, "http://www.facebook.com/logout.php?h=" & Account.Logoff) End Sub Private Sub WaitForBrowser(ByVal Browser As WebBrowser, ByVal URL As String) Dim Start As Date = Date.Now() Call Browser.Navigate(URL) Do While Browser.ReadyState <> WebBrowserReadyState.Complete Application.DoEvents() If SanityCheck(Start) Then Call Browser.Refresh() Loop End Sub Private Function SanityCheck(ByVal TimeStart As Date) As Boolean Return DateDiff(DateInterval.Second, TimeStart, Date.Now) > 30 End Function Private Sub TabControl1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabControl1.SelectedIndexChanged If Busy Or Me.CheckBox1.Checked Then Exit Sub Busy = True Call LogOffAll() Call Login(CType(Details.Item(TabControl1.SelectedIndex() + 1), AccountDetails)) Busy = False End Sub Private Sub LogOffAll() Dim Account As New AccountDetails For Each Account In Details Call WaitForBrowser(Me.WebBrowser7, "http://www.facebook.com/logout.php?h=" & Account.Logoff) Next End Sub Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged If Not Me.CheckBox1.Checked And Not Busy Then Busy = True Call Logoffall() Call Login(CType(Details.Item(TabControl1.SelectedIndex() + 1), AccountDetails)) Busy = False End If End Sub End Class