private async void FacebookLoginButton_Click(object sender, EventArgs e) { LoadingPanel.Visible = true; await Task.Delay(1500); FacebookFirstTime = true; // visible fb web browser FacebookWebBrowser.Visible = true; // suppress script errors FacebookWebBrowser.ScriptErrorsSuppressed = true; try { // remove handler FacebookWebBrowser.DocumentCompleted -= new WebBrowserDocumentCompletedEventHandler(FacebookWebBrowserDocumentCompleted); } catch { } // add handler FacebookWebBrowser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(FacebookWebBrowserDocumentCompleted); // Every time we want to login with another facebook account, we need to clear // all cached and cookies for facebook and instagram addresses. // WebBrowser control uses Internet Explorer so we need to clean up. WebBrowserHelper.ClearForSpecificUrl(FacebookLoginHelper.InstagramUriWithoutWWWAddress.ToString()); WebBrowserHelper.ClearForSpecificUrl(FacebookLoginHelper.InstagramUriAddress.ToString()); WebBrowserHelper.ClearForSpecificUrl(FacebookLoginHelper.InstagramApiAddress.ToString()); WebBrowserHelper.ClearForSpecificUrl(FacebookLoginHelper.FacebookAddress.ToString()); WebBrowserHelper.ClearForSpecificUrl(FacebookLoginHelper.FacebookMobileAddress.ToString()); // wait 3.5 second System.Threading.Thread.Sleep(3500); // navigate to instagram site FacebookWebBrowser.Navigate(FacebookLoginHelper.InstagramUriAddress); do { Application.DoEvents(); System.Threading.Thread.Sleep(1); }while (FacebookWebBrowser.ReadyState != WebBrowserReadyState.Complete); }
private async void FacebookLoginButton_Click(object sender, EventArgs e) { await Task.Delay(1500); // visible fb web browser FacebookWebBrowser.Visible = true; // suppress script errors FacebookWebBrowser.ScriptErrorsSuppressed = true; try { // remove handler FacebookWebBrowser.DocumentCompleted -= new WebBrowserDocumentCompletedEventHandler(FacebookWebBrowserDocumentCompleted); } catch { } // add handler FacebookWebBrowser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(FacebookWebBrowserDocumentCompleted); // Every time we want to login with another facebook account, we need to clear // all cached and cookies for facebook addresses. // WebBrowser control uses Internet Explorer so we need to clean up. WebBrowserHelper.ClearForSpecificUrl(InstaFbHelper.FacebookAddressWithWWWAddress.ToString()); WebBrowserHelper.ClearForSpecificUrl(InstaFbHelper.FacebookAddress.ToString()); WebBrowserHelper.ClearForSpecificUrl(InstaFbHelper.FacebookMobileAddress.ToString()); // wait 3.5 second System.Threading.Thread.Sleep(3500); var facebookLoginUri = InstaFbHelper.GetFacebookLoginUri(); var userAgent = InstaFbHelper.GetFacebookUserAgent(); FacebookWebBrowser.Navigate(facebookLoginUri, null, null, string.Format("\r\nUser-Agent: {0}\r\n", userAgent)); do { Application.DoEvents(); System.Threading.Thread.Sleep(1); }while (FacebookWebBrowser.ReadyState != WebBrowserReadyState.Complete); }