Exemple #1
0
        private void BrowserNavigated(object sender, NavigationEventArgs e)
        {
            FacebookOAuthResult oauthResult;

            if (!client.TryParseOAuthCallbackUrl(e.Uri, out oauthResult))
            {
                BrowserVisibility = Visibility.Visible;
                IsCalculating     = false;
                return;
            }

            IsCalculating = true;
            if (oauthResult.IsSuccess)
            {
                client.AccessToken = oauthResult.AccessToken;
                FacebookClientHelpers.SaveToken(client.AccessToken);
                BrowserVisibility = Visibility.Collapsed;
                PostToWall();
            }
            else
            {
                MessageBox.Show(oauthResult.ErrorDescription);
                BrowserVisibility = Visibility.Collapsed;
            }
        }
Exemple #2
0
        private void Facebook_PostComplete(object sender, FacebookApiEventArgs args)
        {
            //Checking for errors
            if (args.Error != null)
            {
                //Authorization error
                if (args.Error is FacebookOAuthException)
                {
                    Dispatcher.BeginInvoke(() => MessageBox.Show("Authorization Error"));
                    //Remove the actual token since it doesn't work anymore.
                    FacebookClientHelpers.SaveToken(null);
                    client.AccessToken = null;
                }
                else
                {
                    Dispatcher.BeginInvoke(() => MessageBox.Show(args.Error.Message));
                }
            }
            else
            {
                Dispatcher.BeginInvoke(() =>
                {
                    MessageBox.Show("Message posted successfully");
                    NavigationService.GoBack();
                });
            }

            Dispatcher.BeginInvoke(() => IsCalculating = false);
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (e.NavigationMode == NavigationMode.Back)
            {
                return;
            }

            SystemTray.IsVisible = true;
            FacebookClientHelpers.SaveToken(null);
            while (NavigationService.CanGoBack)
            {
                NavigationService.RemoveBackEntry();
            }
        }