Exemplo n.º 1
0
        private async void FbStart()
        {
            try
            {
                FacebookGrid.Visibility = Visibility.Visible;
                SignInVM.LoadingOn();
                using (var client = new HttpClient())
                {
                    var response = await client.GetAsync(InstaFbHelper.FacebookAddress);

                    if (!response.IsSuccessStatusCode)
                    {
                        FacebookGrid.Visibility = Visibility.Collapsed;
                        SignInVM.LoadingOff();
                        FacebookBlockedMsg.ShowMsg();
                        return;
                    }
                }
            }
            catch
            {
                FacebookGrid.Visibility = Visibility.Collapsed;
                SignInVM.LoadingOff();
                FacebookBlockedMsg.ShowMsg();
                return;
            }
            try
            {
                UserAgentHelper.SetUserAgent("Mozilla/5.0 (Linux; Android 4.4; Nexus 5 Build/_BuildID_) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Mobile Safari/537.36");
            }
            catch { }
            try
            {
                DeleteFacebookCookies();
            }
            catch { }
            FacebookGrid.Visibility = Visibility.Visible;
            SignInVM.LoadingOn();
            await Task.Delay(1500);

            var facebookLogin = InstaFbHelper.GetFacebookLoginUri();

            FacebookWebView.Navigate(facebookLogin);
        }
Exemplo n.º 2
0
        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);
        }