using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace StatusUpdater { public partial class FBLoginForm : Form { private MainForm mainForm; public FBLoginForm(MainForm mainForm) { InitializeComponent(); this.mainForm = mainForm; this.webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(this.webBrowser1_DocumentCompleted); this.webBrowser1.ScriptErrorsSuppressed = false; this.webBrowser1.Dock = DockStyle.Fill; base.Controls.Add(this.webBrowser1); this.webBrowser1.Navigate(new Uri("http://www.facebook.com/login.php?api_key=cde8bde5557a5f2f933eefb4de1789af&connect_display=popup&v=1.0&next=http://www.facebook.com/connect/login_success.html&cancel_url=http://www.facebook.com/connect/login_failure.html&fbconnect=true&return_session=true&req_perms=read_stream,publish_stream,offline_access")); } private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { if (this.webBrowser1.Url == null) { MessageBox.Show("Cannot connect to Facebook login page !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); Close(); } if (this.webBrowser1.Url.Query.Contains("?session=")) { string str2 = "session_key%22%3A%22"; string str3 = this.webBrowser1.Url.Query.Substring(this.webBrowser1.Url.Query.IndexOf(str2) + str2.Length); this.mainForm.SESSION_KEY = str3.Split(new char[] { '%' })[0]; string str4 = "secret%22%3A%22"; string str5 = this.webBrowser1.Url.Query.Substring(this.webBrowser1.Url.Query.IndexOf(str4) + str4.Length); this.mainForm.SESSION_SECRET = str5.Split(new char[] { '%' })[0]; Close(); } } } }