public async Task <string> Post(Want want) { var fb = this.data.GetFacebookInfo(); var facebookClient = new Facebook.FacebookClient(fb.AccessToken); var postParams = new { name = string.Format("In Search Of: {0}", want.Title), caption = string.Format("Can anyone help me find: '{0}'?", want.Title), description = want.Description, link = string.Format("http://www.borentra.com/wanted/{0}", want.Key), picture = want.LargeImage, }; string shareMessage = null; try { await facebookClient.PostTaskAsync("/me/feed", postParams); shareMessage = string.Format("Successfully shared: '{0}'.", want.Title); } catch (Exception ex) { shareMessage = string.Format("Unable to post at this time: '{0}'", ex.Message); } return(shareMessage); }
public async static void ShareToFacebook( string Link, string Message, string FriendPicture) { var facebookClient = new Facebook.FacebookClient(App.fbToken); var postParams = new { name = AppResources.ApplicationTitle, caption = AppResources.ApplicationCaption, message = Message, picture = FriendPicture, link = Link }; try { dynamic fbPostTaskResult = await facebookClient.PostTaskAsync("/me/feed", postParams); var result = (IDictionary <string, object>)fbPostTaskResult; MessageBox.ShowAsync(AppResources.FacebookSuccesfulPost, AppResources.Facebook); } catch (Exception ex) { MessageBox.ShowAsync(AppResources.FacebookErrorPost, AppResources.Facebook); } }
/// <summary> /// Post message on Facebook. /// This is done by creating a facebook client and user using the acces token received with the OnNavigatedTo() method. /// The message is typed in by the user. /// </summary> private async void PostOnFb(string fbMessage) { //Checks if user is logged in. if (AccessToken == "0") { var dialog = new MessageDialog("You need to login before you can post on Facebook"); await dialog.ShowAsync(); } else { try { Facebook.FacebookClient fbClient = new Facebook.FacebookClient(AccessToken); dynamic fbUser = await fbClient.GetTaskAsync("me"); if (fbMessage == "") { errorTextBlock.Text = "You cannot place an empty message"; } else { await fbClient.PostTaskAsync("/me/feed", new { message = fbMessage }); var dialog = new MessageDialog("Message is succesfully published on your wall!"); await dialog.ShowAsync(); } } catch (Exception ex) { var dialog = new MessageDialog("An error occured while posting your message on Facebook: " + ex); await dialog.ShowAsync(); } } }
private async void PublishStory() { var fb = new Facebook.FacebookClient(Session.ActiveSession.CurrentAccessTokenData.AccessToken); var postParams = new { name = "Facebook SDK for .NET", caption = "Build great social apps and get more installs.", description = "The Facebook SDK for .NET makes it easier and faster to develop Facebook integrated .NET apps.", link = "http://facebooksdk.net/", picture = "http://facebooksdk.net/assets/img/logo75x75.png" }; try { dynamic fbPostTaskResult = await fb.PostTaskAsync("/me/feed", postParams); var result2 = (IDictionary <string, object>)fbPostTaskResult; var successMessageDialog = new Windows.UI.Popups.MessageDialog("Posted Open Graph Action, id: " + (string)result2["id"]); await successMessageDialog.ShowAsync(); } catch (Exception ex) { MessageDialogHelper.Show("Exception during post: " + ex.Message); } }
private async void PostToWall(string status, string fbtoken) { try { facebookClient = new Facebook.FacebookClient(fbtoken); var parameters = new Dictionary <string, object>(); var parameters1 = new Dictionary <string, object>(); parameters["message"] = status; dynamic fbPostTaskResult = await facebookClient.PostTaskAsync("/me/feed", parameters); var result = (IDictionary <string, object>)fbPostTaskResult; Deployment.Current.Dispatcher.BeginInvoke(() => { string toastMessage = "Posted Open Graph Action, id: " + (string)result["id"]; ShellToast toast = new ShellToast(); toast.Title = "Background Agent Sample"; toast.Content = toastMessage; toast.Show(); completedUpdates++; if (completedUpdates == scheduledUpdates) { notify(); } //NotifyComplete(); //MessageBox.Show("Posted Open Graph Action, id: " + (string)result["id"], "Result", MessageBoxButton.OK); }); } catch (Exception ex) { Deployment.Current.Dispatcher.BeginInvoke(() => { string toastMessage = "" + ex.ToString(); ShellToast toast = new ShellToast(); toast.Title = "."; toast.Content = toastMessage; toast.Show(); error = error + toastMessage; completedUpdates++; if (completedUpdates == scheduledUpdates) { notify(); } //NotifyComplete(); //MessageBox.Show("Exception during post: " + ex.ToString(), "Error", MessageBoxButton.OK); }); } }
void share(int sid, string name, string caption, string description, string url, string picture) { try{ Deployment.Current.Dispatcher.BeginInvoke(async () => { bool shared_ok = false; try { var fb = new Facebook.FacebookClient(session.AccessToken); var postParams = new { name = name, caption = caption, description = description, link = url, picture = picture }; dynamic fbPostTaskResult = await fb.PostTaskAsync("/me/feed", postParams); var result = (IDictionary<string, object>)fbPostTaskResult; shared_ok = true; } catch (Exception) { } ADFacebookWP8Impl.sendShareResult(sid, shared_ok); }); } catch (Exception e){} }
private async void PublishStory() { isi.DefaultItem = post; IsWait(); await this.loginButton.RequestNewPermissions("publish_stream"); var facebookClient = new Facebook.FacebookClient(this.loginButton.CurrentSession.AccessToken); var postParams = new { /* name = "Facebook SDK for .NET", caption = "Build great social apps and get more installs.", description = "The Facebook SDK for .NET makes it easier and faster to develop Facebook integrated .NET apps.", link = "http://facebooksdk.net/", picture = "http://facebooksdk.net/assets/img/logo75x75.png" */ message = postKata.Text }; try { isi.DefaultItem = post; IsWait(); dynamic fbPostTaskResult = await facebookClient.PostTaskAsync("/me/feed", postParams); var result = (IDictionary<string, object>)fbPostTaskResult; isi.DefaultItem = post; NotWait(); MessageBox.Show("Post berhasil dilakukan"); } catch (Exception ex) { NotWait(); MessageBox.Show("Post gagal dilakukan"); } }
public async static void ShareToFacebook( string Link, string Message, string FriendPicture) { var facebookClient = new Facebook.FacebookClient(App.fbToken); var postParams = new { name = AppResources.ApplicationTitle, caption = AppResources.ApplicationCaption, message = Message, picture = FriendPicture, link = Link }; try { dynamic fbPostTaskResult = await facebookClient.PostTaskAsync("/me/feed", postParams); var result = (IDictionary<string, object>)fbPostTaskResult; MessageBox.ShowAsync(AppResources.FacebookSuccesfulPost, AppResources.Facebook); } catch (Exception ex) { MessageBox.ShowAsync(AppResources.FacebookErrorPost, AppResources.Facebook); } }