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; } }
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(); } }
protected override void OnNavigatedTo(NavigationEventArgs e) { if (e.NavigationMode == NavigationMode.Back) { return; } _pictureName = HttpUtility.UrlDecode(NavigationContext.QueryString["image"]); _pictureWidth = int.Parse(NavigationContext.QueryString["width"]); _pictureHeight = int.Parse(NavigationContext.QueryString["height"]); Image = LocalImagesHelper.ReadImageFromIsolatedStorage(_pictureName, _pictureWidth, _pictureHeight); client = new FacebookClient(); client.PostCompleted += Facebook_PostComplete; //Checking for saved token if (FacebookClientHelpers.GetToken() != null) { client.AccessToken = FacebookClientHelpers.GetToken(); } }