private void btnUpload_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(_filename)) { MessageBox.Show("Please select the image file first."); return; } var mediaObject = new FacebookMediaObject { ContentType = "image/jpeg", FileName = Path.GetFileName(_filename) } .SetValue(File.ReadAllBytes(_filename)); progressBar1.Value = 0; var fb = new FacebookClient(_accessToken); fb.UploadProgressChanged += fb_UploadProgressChanged; fb.PostCompleted += fb_PostCompleted; // for cancellation _fb = fb; fb.PostAsync("/me/photos", new Dictionary<string, object> { { "source", mediaObject } }); }
/// <summary> /// /// </summary> /// <param name="name">Name of event</param> /// <param name="description">Description</param> /// <param name="startTime">Start Time, UNIX format= 2012-06-14T12:22:23</param> /// <param name="endTime">End Time, not needde</param> /// <param name="location">Location</param> /// <param name="privacy">Privacy type</param> public void CreateEvent(string name, string description, string startTime, string endTime, string location, EventPrivacy privacy) { RFBClient = new FacebookClient(FBAuthenticationService.AccessToken); RFBClient.PostCompleted += new EventHandler<FacebookApiEventArgs>(RFBClient_PostCompleted); RFBClient.PostAsync(FetchString, new { name = name, start_time = startTime, end_time = endTime, description = description, location = location, privacy_type = privacyToString(privacy) }); }
void Upload(bool fUsingSavedAccessToken) { FacebookClient fb = new FacebookClient(this.accessToken); // make sure to add event handler for PostCompleted. fb.PostCompleted += (o, e) => { if (e.Error != null) { if (fUsingSavedAccessToken && e.Error is Facebook.FacebookOAuthException) { //the access token is invalid (maybe expired) //Application.Current.Dispatcher.BeginInvoke(new Action(() => // { // Config.FacebookAccessToken = null; // this.AuthAndUpload(filePath); // } //)); App.Instance.BeginInvoke(new Action(() => { Config.FacebookAccessToken = null; this.AuthAndUpload(filePath); } )); } else { App.Instance.AddError(Config.FACEBOOK_ERROR, Config.FACEBOOK_TITLE); } } else { App.Instance.AddMessage(Config.FACEBOOK_SUCCEED, Config.FACEBOOK_TITLE); } }; var photoDetail = new Dictionary<string, object>(); photoDetail.Add("message", message); photoDetail.Add("source", new FacebookMediaObject { ContentType = "image/png", FileName = filePath }.SetValue(File.ReadAllBytes(filePath))); fb.PostAsync("me/photos", photoDetail); //dynamic parameters = new ExpandoObject(); //parameters.message = "Posted from Clipoff"; //parameters.source = new FacebookMediaObject //{ // ContentType = "image/png", // FileName = filePath //}.SetValue(File.ReadAllBytes(filePath)); //fb.PostAsync("me/photos", parameters); }
public void SetRsvp(string name, ActivityItemsViewModel act) { if (App.ViewModel.UserPreference.AccessKey == null || act.FacebookId == null || act.FacebookId.Equals("") || !App.ViewModel.HasConnection) return; var fb = new FacebookClient { AccessToken = App.ViewModel.UserPreference.AccessKey, AppId = App.ViewModel.Appid }; fb.GetCompleted += (o, e) => { if (e.Error != null) { Deployment.Current.Dispatcher.BeginInvoke( () => MessageBox.Show( "Er gebeurde een fout tijdens het versturen van data naar Facebook")); } act.RsvpStatus = GetRsvp(act).ToString(); }; var query = string.Format("https://graph.facebook.com/{0}/{1}", act.FacebookId, name); fb.PostAsync(query, null); }
public void ShareOnFacebook() { string post = ""; post = ""; if (ffid == " " && fftoken == " " || ffid == null && fftoken == null) { NavigationService.Navigate(new Uri(string.Format("/FacebookLoginPage.xaml?vpost={0}", post), UriKind.Relative)); } else { var fb = new FacebookClient(fftoken); fb.PostCompleted += (o, e) => { if (e.Cancelled || e.Error != null) { Dispatcher.BeginInvoke(() => MessageBox.Show(e.Error.Message)); return; } var result = e.GetResultData(); Dispatcher.BeginInvoke(() => { progbar1.IsIndeterminate = false; progbar1.Visibility = Visibility.Collapsed; // MessageBox.Show("Successfully shared on Facebook"); //if (NavigationService.CanGoBack) // NavigationService.GoBack(); buyNowScreen = new Popup(); buyNowScreen.Child = new NotifyAlert ("Successfully shared on Facebook"); buyNowScreen.IsOpen = true; buyNowScreen.VerticalOffset = 0; buyNowScreen.HorizontalOffset = 0; }); }; //IsolatedSettingsHelper.SetValue<bool>("sharedonfacebook", true); //Dispatcher.BeginInvoke(() => //{ // buyNowScreen = new Popup(); // buyNowScreen.Child = // new NotifyAlert // ("Successfully shared on Facebook"); // buyNowScreen.IsOpen = true; // buyNowScreen.VerticalOffset = 0; // buyNowScreen.HorizontalOffset = 0; //}); var parameters = new Dictionary<string, object>(); parameters["name"] = photo_text.Text; var resized = img.Resize(img.PixelWidth / 2, img.PixelHeight / 2, WriteableBitmapExtensions.Interpolation.Bilinear); var fileStream = new MemoryStream(); resized.SaveJpeg(fileStream, resized.PixelWidth, resized.PixelHeight, 100, 100); fileStream.Seek(0, SeekOrigin.Begin); parameters["TestPic"] = new FacebookMediaObject { ContentType = "image/jpeg", FileName = fileName + ".jpg" }.SetValue(fileStream.ToArray());//.SetValue(photoStream.ToArray()); //fb.PostCompleted += fb_PostCompleted; fb.PostAsync("me/Photos", parameters); string channel = IsolatedSettingsHelper.GetValue<string>("latest_update_channel"); IsolatedSettingsHelper.SetValue<string>("latest_update", "You shared a photo"); IsolatedSettingsHelper.SetValue<string>("latest_update_channel", channel + " Facebook"); IsolatedSettingsHelper.SetValue<string>("latest_update_time", DateTime.Now.ToString()); } }
/// <summary> /// Post on wall of Facebook user /// </summary> public void WallPost() { var fb = new FacebookClient(_accessToken); fb.PostCompleted += (o, args) => { if (args.Error != null) { Dispatcher.BeginInvoke(() => MessageBox.Show(args.Error.Message)); return; } var result = (IDictionary<string, object>) args.GetResultData(); _lastMessageId = (string) result["id"]; Dispatcher.BeginInvoke(() => { MessageBox.Show("Message Posted successfully"); txtAnswer.Text = string.Empty; btnDeletePost.IsEnabled = true; }); }; var parameters = new Dictionary<string, object>(); parameters["message"] = txtInput.Text; fb.PostAsync("me/feed", parameters); // post message on wall of user }
/// <summary> /// Checkin current location of user on facebook /// </summary> public void CheckIn() { var fb = new FacebookClient(_accessToken); fb.PostCompleted += (o, args) => { if (args.Error != null) { Dispatcher.BeginInvoke(() => MessageBox.Show(args.Error.Message)); return; } var result = (IDictionary<string, object>)args.GetResultData(); _lastMessageId = (string)result["id"]; // get result id of post Dispatcher.BeginInvoke(() => { MessageBox.Show("Checkin done successfully"); }); }; var parameters = new Dictionary<string, object>(); //parameters["message"] = txtInput.Text; parameters["place"] = "173205796066382"; // place of check in parameters["coordinates"] = "28.627116663763,77.375440942471"; // coordinates of checkin // post for checkin fb.PostAsync("me/feed", parameters); }
private void Publicar(string arg1, string name, string time, string message = "") { try { string test = GetPageAccessToken(_accessToken); var Variab = new Variables(); var fb = new FacebookClient(test); // make sure to add event handler for PostCompleted. fb.PostCompleted += (o, e) => { // incase you support cancellation, make sure to check // e.Cancelled property first even before checking (e.Error!=null). if (e.Cancelled) { // for this example, we can ignore as we don't allow this // example to be cancelled. // you can check e.Error for reasons behind the cancellation. var cancellationError = e.Error; } else if (e.Error != null) { // error occurred this.BeginInvoke(new MethodInvoker( () => { //MessageBox.Show(e.Error.Message); })); } else { // the request was completed successfully // now we can either cast it to IDictionary<string, object> or IList<object> // depending on the type. or we could use dynamic. dynamic result = e.GetResultData(); _lastMessageId = result.id; // make sure to be on the right thread when working with ui. this.BeginInvoke(new MethodInvoker( () => { //MessageBox.Show("Message Posted successfully"); //txtMessage.Text = string.Empty; //btnDeleteLastMessage.Enabled = true; })); } }; dynamic parameters = new ExpandoObject(); parameters.privacy = new { value = "ALL_FRIENDS", }; parameters.name = name; parameters.message = message; if (arg1.Contains("/wow/en/item/") == true) { parameters.link = "http://us.battle.net" + arg1; } else { parameters.link = "http://us.battle.net/" + arg1; } //parameters.link = "http://us.battle.net/wow/en/character/quelthalas/Amadoflimd/" + arg1; //s.ResponseUri.AbsoluteUri parameters.caption = "Realm: " + Variables.Realm; fb.PostAsync("/" + Variables.PageID + "/feed", parameters); StreamWriter sw = new StreamWriter("C:\\UpdatesGuild.txt", true); //Write a line of text sw.WriteLine(name); //sw.WriteLine(Environment.NewLine); //sw.Flush(); //Close the file sw.Close(); } catch (Exception ex) { } }
public static void PostToWall(string msg) { if (wasLoginCancelled == true) Login(); if (LoggedIn != true) throw new Exception("User is not logged in!"); var fb = new FacebookClient(AccessToken); // make sure to add event handler for PostCompleted. fb.PostCompleted += (o, e) => { // incase you support cancellation, make sure to check // e.Cancelled property first even before checking (e.Error!=null). if (e.Cancelled) { // for this example, we can ignore as we don't allow this // example to be cancelled. // you can check e.Error for reasons behind the cancellation. throw e.Error; } else if (e.Error != null) { // error occurred throw e.Error; } else { // the request was completed successfully // now we can either cast it to IDictionary<string, object> or IList<object> // depending on the type. or we could use dynamic. dynamic result = e.GetResultData(); //_lastMessageId = result.id; } }; dynamic parameters = new ExpandoObject(); parameters.message = msg; fb.PostAsync("me/feed", parameters); }
private void button3_Click(object sender, RibbonControlEventArgs e) { if (ThisAddIn.GetAccessToken() == "") { MessageBox.Show("請先登入!", "Facebook", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } string select = ""; try { PowerPoint._Application myPPT = Globals.ThisAddIn.Application; var Sld = myPPT.ActiveWindow.View.Slide; select = myPPT.ActiveWindow.Selection.TextRange.Text; } catch (Exception ex) { MessageBox.Show("請選取文字!", "Facebook", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } if (select != "") { FacebookClient facebook = new FacebookClient(ThisAddIn.GetAccessToken()); // 使用 Token 建立一個 FacebookClient var parameters = new Dictionary<String, Object>(); facebook.PostCompleted += OnFacebookPostCompleted; DateTime dt = DateTime.Now; parameters["message"] = select; facebook.PostAsync("me/feed", parameters); } else { MessageBox.Show("請選取文字!", "Facebook", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } }
private void btnPostToWall_Click(object sender, EventArgs args) { var fb = new FacebookClient(_accessToken); // make sure to add event handler for PostCompleted. fb.PostCompleted += (o, e) => { // incase you support cancellation, make sure to check // e.Cancelled property first even before checking (e.Error!=null). if (e.Cancelled) { // for this example, we can ignore as we don't allow this // example to be cancelled. // you can check e.Error for reasons behind the cancellation. var cancellationError = e.Error; } else if (e.Error != null) { // error occurred this.BeginInvoke(new MethodInvoker( () => { MessageBox.Show(e.Error.Message); })); } else { // the request was completed successfully // now we can either cast it to IDictionary<string, object> or IList<object> // depending on the type. or we could use dynamic. dynamic result = e.GetResultData(); _lastMessageId = result.id; // make sure to be on the right thread when working with ui. this.BeginInvoke(new MethodInvoker( () => { MessageBox.Show("Message Posted successfully"); txtMessage.Text = string.Empty; btnDeleteLastMessage.Enabled = true; })); } }; dynamic parameters = new ExpandoObject(); parameters.message = txtMessage.Text; fb.PostAsync("me/feed", parameters); }
private void postMessage() { if (this.currentWord == null) { MessageBox.Show("Enter message."); return; } var fb = new FacebookClient(_accessToken); fb.PostCompleted += (o, args) => { if (args.Error != null) { Dispatcher.BeginInvoke(() => MessageBox.Show(args.Error.Message)); return; } var result = (IDictionary<string, object>)args.GetResultData(); _lastMessageId = (string)result["id"]; Dispatcher.BeginInvoke(() => { MessageBox.Show(AppResources.thankYou); }); }; var parameters = new Dictionary<string, object>(); //parameters["message"] = this.currentOffer.Title; parameters["name"] = this.currentWord.WordContent; parameters["caption"] = this.currentWord.Description; parameters["description"] = this.currentWord.Example; parameters["link"] = "http://www.neolog.bg/word/" + this.currentWord.WordId; fb.PostAsync("me/feed", parameters); Dispatcher.BeginInvoke(() => { NavigationService.GoBack(); }); }
private void LoginSucceded(string accessToken) { var fb = new FacebookClient(accessToken); fb.GetCompleted += (o, e) => { if (e.Error != null) { Dispatcher.BeginInvoke(() => MessageBox.Show(e.Error.Message)); return; } var result = (IDictionary<string, object>)e.GetResultData(); var id = (string)result["id"]; IsolatedSettingsHelper.SetValue<string>("ftoken_sharetoall", accessToken); IsolatedSettingsHelper.SetValue<string>("fid_sharetoall", id); // string _post = NavigationContext.QueryString["vpost"]; Dispatcher.BeginInvoke(() => { MessageBox.Show("Successfully shared on Facebook"); }); if (_post.Contains('|')) { string[] words = _post.Split('|'); var parameters = new Dictionary<string, object>(); //parameters["message"] = txtMessage.Text; parameters["message"] = words[0]; parameters["link"] = words[1]; //parameters["picture"] = ""; fb.PostAsync("me/feed", parameters); } else { var parameters = new Dictionary<string, object>(); //parameters["message"] = txtMessage.Text; parameters["message"] = _post; // parameters["link"] = words[1]; //parameters["picture"] = ""; fb.PostAsync("me/feed", parameters); } ////////// }; fb.GetAsync("me?fields=id"); }
private void webBrowser1_Navigated(object sender, System.Windows.Navigation.NavigationEventArgs e) { // whenever the browser navigates to a new url, try parsing the url // the url may be the result of OAuth 2.0 authentication. FacebookOAuthResult oauthResult; var fb = new FacebookClient(); if (fb.TryParseOAuthCallbackUrl(e.Uri, out oauthResult)) { // The url is the result of OAuth 2.0 authentication. if (oauthResult.IsSuccess) { // we got the code here fb.PostCompleted+= (o, args) => { // make sure to check that no error has occurred. if (args.Error != null) { // make sure to access ui stuffs on the correct thread. Dispatcher.BeginInvoke( () => { MessageBox.Show(args.Error.Message); NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative)); }); } else { var result = (IDictionary<string, object>)args.GetResultData(); var accessToken = (string)result["access_token"]; // make sure to access ui stuffs on the correct thread. Dispatcher.BeginInvoke(() => NavigationService.Navigate(new Uri("/FacebookInfoPage.xaml?access_token=" + accessToken, UriKind.Relative))); } }; fb.PostAsync("oauth/access_token",new { client_id = AppId, client_secret = AppSecret, redirect_uri = RedirectUri, code = oauthResult.Code }); } else { // the user clicked don't allow or some other error occurred. MessageBox.Show(oauthResult.ErrorDescription); } } else { // The url is NOT the result of OAuth 2.0 authentication. } }
public void ShareOnFacebook() { //ShowProgressIndicator(AppResources.GettingLocationProgressText); string post = ""; post = update_text.Text; if (ffid == " " && fftoken == " " || ffid == null && fftoken == null) { NavigationService.Navigate(new Uri(string.Format("/FacebookLoginPage.xaml?vpost={0}", post), UriKind.Relative)); } else { var fb = new FacebookClient(fftoken); fb.PostCompleted += (o, args) => { if (args.Error != null) { if (args.Error.Message == "(OAuthException - #506) (#506) Duplicate status message") { Dispatcher.BeginInvoke(() => MessageBox.Show("You have already shared it!")); return; } else { Dispatcher.BeginInvoke(() => MessageBox.Show(args.Error.Message)); return; } } var result = (IDictionary<string, object>)args.GetResultData(); _lastMessageId = (string)result["id"]; string channel= IsolatedSettingsHelper.GetValue<string>("latest_update_channel"); IsolatedSettingsHelper.SetValue<string>("latest_update", post); IsolatedSettingsHelper.SetValue<string>("latest_update_channel", channel +" Facebook"); IsolatedSettingsHelper.SetValue<string>("latest_update_time", DateTime.Now.ToString()); //Dispatcher.BeginInvoke(() => //{ // // MessageBox.Show("Successfully shared on Facebook"); //}); Dispatcher.BeginInvoke(() => { buyNowScreen1 = new Popup(); buyNowScreen1.Child = new NotifyAlert ("Successfully shared on Facebook"); buyNowScreen1.IsOpen = true; buyNowScreen1.VerticalOffset = 0; buyNowScreen1.HorizontalOffset = 0; }); //IsolatedSettingsHelper.SetValue<bool>("sharedonfacebook", true); }; // string[] words = post.Split('|'); var parameters = new Dictionary<string, object>(); //parameters["message"] = txtMessage.Text; parameters["message"] = post; //parameters["link"] = words[1]; //parameters["picture"] = ""; fb.PostAsync("me/feed", parameters); progbar.IsIndeterminate = false; progbar.Visibility = Visibility.Collapsed; // HideProgressIndicator(); } }
public void Share(Movie m, string message) { var accessToken = SettingsManager.FacebookToken; FacebookClient fb= new FacebookClient(accessToken); fb.PostCompleted += (o, args) => { if (args.Error != null) { OnComplete(new FacebookResult() { Error = args.Error }); } else { OnComplete(new FacebookResult() { Result = (IDictionary<string, object>)args.GetResultData() }); //var result = (IDictionary<string, object>)args.GetResultData(); //_lastMessageId = (string)result["id"]; } }; var parameters = new Dictionary<string, object>(); parameters["caption"] = "Checa 'My Movies' en Windows Phone!"; parameters["message"] = message; parameters["name"] = m.Title; parameters["description"] = m.Sinopsis; parameters["picture"] = m.PosterUri; parameters["link"] = m.MovieUri; fb.PostAsync("me/feed", parameters); }
private void btnPostToWall_Click(object sender, EventArgs args) { //// Scrape links from wikipedia.org //string quest = "On+to+Kharanos"; //// 1. //// URL: http://en.wikipedia.org/wiki/Main_Page //WebClient w = new WebClient(); //string s = w.DownloadString("http://es.wowhead.com/search?q=" + quest + "#quests"); //// 2. //foreach (LinkItem i in LinkFinder.Find(s)) //{ // Debug.WriteLine(i); // //Link = i; // if (i.Text.Contains(quest.Replace("+","_"))) // { // link = i.Text; // } //} var fb = new FacebookClient(_accessToken); // make sure to add event handler for PostCompleted. fb.PostCompleted += (o, e) => { // incase you support cancellation, make sure to check // e.Cancelled property first even before checking (e.Error!=null). if (e.Cancelled) { // for this example, we can ignore as we don't allow this // example to be cancelled. // you can check e.Error for reasons behind the cancellation. var cancellationError = e.Error; } else if (e.Error != null) { // error occurred this.BeginInvoke(new MethodInvoker( () => { //MessageBox.Show(e.Error.Message); })); } else { // the request was completed successfully // now we can either cast it to IDictionary<string, object> or IList<object> // depending on the type. or we could use dynamic. dynamic result = e.GetResultData(); _lastMessageId = result.id; // make sure to be on the right thread when working with ui. this.BeginInvoke(new MethodInvoker( () => { MessageBox.Show("Message Posted successfully"); //txtMessage.Text = string.Empty; //btnDeleteLastMessage.Enabled = true; })); } }; dynamic parameters = new ExpandoObject(); parameters.privacy = new { value = "ALL_FRIENDS", }; //parameters.message = txtMessage.Text; parameters.name = "Mision Aceptada"; parameters.link = "http://www.google.com"; parameters.caption = "Una prueba de atachment"; fb.PostAsync("/me/feed", parameters); }
/// <summary> /// picture post to facebook /// <summary> public void postToFB(String url, byte[] data, Action retf) { FacebookClient _fbClient = new FacebookClient(_accessToken); var parameters = new Dictionary<string, object>(); parameters["message"] = "WP7 app presentation"; parameters["file"] = new FacebookMediaObject { ContentType = "image/jpeg", FileName = "image.jpg" }.SetValue(data); _fbClient.PostCompleted += _fbClient_PostCompleted; // async request _fbClient.PostAsync(url, parameters, retf); }
private void btnPostVideo_Click(object sender, EventArgs args) { var ofd = new OpenFileDialog { Filter = "MP4 Files|*.mp4", Title = "Select video to upload" }; if (ofd.ShowDialog() != DialogResult.OK) { return; } var fb = new FacebookClient(_accessToken); // make sure to add event handler for PostCompleted. fb.PostCompleted += (o, e) => { // incase you support cancellation, make sure to check // e.Cancelled property first even before checking (e.Error!=null). if (e.Cancelled) { // for this example, we can ignore as we don't allow this // example to be cancelled. // you can check e.Error for reasons behind the cancellation. var cancellationError = e.Error; } else if (e.Error != null) { // error occurred this.BeginInvoke(new MethodInvoker( () => { //MessageBox.Show(e.Error.Message); })); } else { // the request was completed successfully // make sure to be on the right thread when working with ui. this.BeginInvoke(new MethodInvoker( () => { MessageBox.Show("Video uploaded successfully"); })); } }; dynamic parameters = new ExpandoObject(); //parameters.message = txtMessage.Text; parameters.source = new FacebookMediaObject { ContentType = "video/mp4", FileName = Path.GetFileName(ofd.FileName) }.SetValue(File.ReadAllBytes(ofd.FileName)); fb.PostAsync("me/videos", parameters); }
private void postMessage() { if (this.currentOffer == null) NavigationService.GoBack(); var fb = new FacebookClient(_accessToken); fb.PostCompleted += (o, args) => { if (args.Error != null) { Dispatcher.BeginInvoke(() => MessageBox.Show(args.Error.Message)); return; } var result = (IDictionary<string, object>)args.GetResultData(); _lastMessageId = (string)result["id"]; }; var parameters = new Dictionary<string, object>(); //parameters["message"] = this.currentOffer.Title; parameters["name"] = this.currentOffer.Title; parameters["caption"] = this.currentOffer.Positivism; parameters["description"] = this.currentOffer.Negativism; parameters["link"] = "http://bombajob.bg/offer/" + this.currentOffer.OfferId; fb.PostAsync("me/feed", parameters); Dispatcher.BeginInvoke(() => { if (MessageBox.Show(AppResources.offer_ThankYou) == MessageBoxResult.OK) NavigationService.GoBack(); }); }
public static void PostToFriendsWall(User u, string msg) { if (wasLoginCancelled == true) Login(); if (LoggedIn != true) throw new Exception("User is not logged in!"); var fb = new FacebookClient(AccessToken); // make sure to add event handler for PostCompleted. fb.PostCompleted += (o, e) => { if (e.Cancelled) { throw e.Error; } else if (e.Error != null) { throw e.Error; } else { dynamic result = e.GetResultData(); } }; dynamic parameters = new ExpandoObject(); parameters.message = msg; //MessageBox.Show("post to " + u.ID + "'s wall"); fb.PostAsync("/" + u.ID + "/feed", parameters); }
public void Post_Without_Click() { sdk.ShowMyLocationOnTheMap2(); make_string_for_address(); make_string_for_image(); txtMessage.Text = ""; StreamReader streamReader = new StreamReader(@"msgfb"); string var = streamReader.ReadLine(); txtMessage.Text = txtMessage.Text + var + final_image + final_xml; if (string.IsNullOrEmpty(txtMessage.Text)) { MessageBox.Show("Enter message."); return; } //MessageBox.Show(txtMessage.Text); var fb = new FacebookClient(_accessToken); fb.PostCompleted += (o, args) => { if (args.Error != null) { Dispatcher.BeginInvoke(() => MessageBox.Show(args.Error.Message)); return; } var result = (IDictionary<string, object>)args.GetResultData(); _lastMessageId = (string)result["id"]; Dispatcher.BeginInvoke(() => { // MessageBox.Show("Message Posted successfully"); txtMessage.Text = string.Empty; btnDeleteLastMessage.IsEnabled = true; }); }; var parameters = new Dictionary<string, object>(); parameters["message"] = txtMessage.Text; fb.PostAsync("me/feed", parameters); NavigationService.Navigate(new Uri("/panic_mode.xaml", UriKind.Relative)); }
void wbFacebook_Navigated(object sender, System.Windows.Navigation.NavigationEventArgs args) { FacebookOAuthResult oauthResult; if (_fb.TryParseOAuthCallbackUrl(args.Uri, out oauthResult)) { this.FacebookOAuthResult = oauthResult; if (this.FacebookOAuthResult.IsSuccess) { string _accessToken = this.FacebookOAuthResult.AccessToken; var fb = new FacebookClient(_accessToken); fb.PostCompleted += (o, e) => { if (e.Cancelled) return; else if (e.Error != null) Caliburn.Micro.Execute.OnUIThread(() => IoC.Get<IWindowManager>().ShowMessageBox(Properties.Resources.share_FacebookError + "\n" + e.Error.Message, Properties.Resources.errorTitle, MessageBoxButton.OK)); else Caliburn.Micro.Execute.OnUIThread(() => IoC.Get<IWindowManager>().ShowMessageBox(Properties.Resources.share_FacebookOK, Properties.Resources.share_Facebook, MessageBoxButton.OK)); }; dynamic parameters = new ExpandoObject(); parameters.picture = "http://bombajob.bg/images/ibombajob.png"; parameters.name = this.currentOffer.Title; parameters.link = "http://bombajob.bg/offer/" + this.currentOffer.OfferID; parameters.caption = this.currentOffer.Positivism; parameters.description = this.currentOffer.Negativism; fb.PostAsync("me/feed", parameters); this.TryClose(); } } else this.FacebookOAuthResult = null; }
private void UploadPhoto() { if (!File.Exists(_filename)) { lblStatus.Text = GlobalSetting.LangPack.Items["frmFacebook._StatusInvalid"]; return; } var mediaObject = new FacebookMediaObject { ContentType = "image/jpeg", FileName = Path.GetFileName(_filename) }.SetValue(File.ReadAllBytes(_filename)); lblPercent.Text = "0 %"; picStatus.Visible = true; lblStatus.Text = GlobalSetting.LangPack.Items["frmFacebook._StatusUploading"]; var fb = new FacebookClient(GlobalSetting.FacebookAccessToken); fb.UploadProgressChanged += fb_UploadProgressChanged; fb.PostCompleted += fb_PostCompleted; // for cancellation _fb = fb; fb.PostAsync("/me/photos", new Dictionary<string, object> { { "source", mediaObject }, { "message", txtMessage.Text.Trim() } }); }
/// <summary> /// Post photo on wall of facebook user /// </summary> public void PostPhoto() { var facebookClient = new FacebookClient(_accessToken); FacebookMediaStream media = new FacebookMediaStream {ContentType = "image/jpeg", FileName = "test Image"}; media.SetValue(_imgStream); facebookClient.PostCompleted += (o, args) => { if (args.Error != null) { Dispatcher.BeginInvoke(() => MessageBox.Show(args.Error.Message)); return; } var result = (IDictionary<string, object>) args.GetResultData(); _lastMessageId = (string) result["id"]; Dispatcher.BeginInvoke(() => { MessageBox.Show( "Message Posted successfully"); btnDeletePost.IsEnabled = true; }); }; IDictionary<string, object> parameters = new Dictionary<string, object>(); //// to upload photo with link //parameters["name"] = "Check this out"; //parameters["link"] = "www.xyz.com"; //parameters["caption"] = "xyz dot com"; //parameters["description"] = "Test url hello how are you, Black Code , Media Test"; //parameters["picture"] = media; //parameters["message"] = "Check this out"; //parameters["actions"] = ""; //facebookClient.PostAsync("me/feed", parameters); // to upload only photo with message parameters["message"] = "Photo upload test " + DateTime.Now.ToString(); parameters["file"] = media; facebookClient.PostAsync("me/Photos", parameters); // post photo on wall }
private void PerformShare() { DataModel.NewsItem c = CurrentNewsItem; var args = new Dictionary<string, object>(); args["name"] = c.NewsTitle; args["link"] = c.NewsLink; args["caption"] = ""; args["description"] = c.NewsSnippet; args["picture"] = ""; args["message"] = ""; args["actions"] = ""; var fb = new FacebookClient(App.AccessToken); fb.PostAsync("me/feed", args); //RadMessageBox.Show("", vibrate: false, verticalAlignment: VerticalAlignment.Center); if (this.NavigationService.CanGoBack) { this.NavigationService.GoBack(); } }
private void PostToWall() { var fb = new FacebookClient(States.accessToken); // make sure to add event handler for PostCompleted. fb.PostCompleted += (o, args) => { // incase you support cancellation, make sure to check // e.Cancelled property first even before checking (e.Error!=null). if (args.Cancelled) { // for this example, we can ignore as we don't allow this // example to be cancelled. // you can check e.Error for reasons behind the cancellation. var cancellationError = args.Error; } else if (args.Error != null) { // error occurred Dispatcher.BeginInvoke(() => { MessageBox.Show(args.Error.Message); }); } else { // the request was completed successfully // now we can either cast it to IDictionary<string, object> or IList<object> var result = (IDictionary<string, object>)args.GetResultData(); var _lastMessageId = (string)result["id"]; // make sure to be on the right thread when working with ui. Dispatcher.BeginInvoke(() => { MessageBox.Show("Report posted to facebook succesfully"); this.NavigationService.Navigate(new Uri("/Pages/MainPage.xaml", UriKind.RelativeOrAbsolute)); }); } }; var parameters = new Dictionary<string, object> { { "message", "I have just posted a " + newReport.Mood + " report about " + newReport.Authority.Name +"!" }, { "link", newReport.Photo }, { "picture", newReport.Photo }, { "name", "This is what I have to say:" }, { "caption", "Posted with Dobberman App" }, { "description", newReport.Description }, }; fb.PostAsync(newReport.Authority.FacebookPage + "/feed", parameters); }
private void PostToWall_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(txtMessage.Text)) { MessageBox.Show("Enter message."); return; } var fb = new FacebookClient(_accessToken); // make sure to add event handler for PostCompleted. fb.PostCompleted += (o, args) => { // incase you support cancellation, make sure to check // e.Cancelled property first even before checking (e.Error!=null). if (args.Cancelled) { // for this example, we can ignore as we don't allow this // example to be cancelled. // you can check e.Error for reasons behind the cancellation. var cancellationError = args.Error; } else if (args.Error != null) { // error occurred Dispatcher.BeginInvoke(() => { MessageBox.Show(args.Error.Message); }); } else { // the request was completed successfully // now we can either cast it to IDictionary<string, object> or IList<object> var result = (IDictionary<string, object>)args.GetResultData(); _lastMessageId = (string)result["id"]; // make sure to be on the right thread when working with ui. Dispatcher.BeginInvoke(() => { MessageBox.Show("Message Posted successfully"); txtMessage.Text = string.Empty; btnDeleteLastMessage.IsEnabled = true; }); } }; var parameters = new Dictionary<string, object>(); parameters["message"] = txtMessage.Text; fb.PostAsync("me/feed", parameters); }
private void uploadFacebook(string file) { if (fallyGrab.Properties.Settings.Default.uploadType == "Facebook") { if (fallyGrab.Properties.Settings.Default.fbToken != "") { var fb = new FacebookClient(Security.DecryptString(fallyGrab.Properties.Settings.Default.fbToken, Security.encryptionPassw)); fb.PostCompleted += (o, e) => { if (e.Cancelled) { var cancellationError = e.Error; } else if (e.Error != null) { // error occurred this.BeginInvoke(new MethodInvoker( () => { fallyToast.Toaster alertformfbe = new fallyToast.Toaster(); alertformfbe.Show("fallyGrab", e.Error.Message, -1, "Fade", "Up", "", "", "error"); })); } else { // the request was completed successfully this.BeginInvoke(new MethodInvoker( () => { dynamic result = e.GetResultData(); string linkFB = "https://www.facebook.com/photo.php?fbid=" + result.id; // Url shortening string shorturl = ""; if (fallyGrab.Properties.Settings.Default.shortenUrls == 1) shorturl = ShortUrl.shortenUrl(linkFB); // copy to clipboard string urlnotif = ""; if (shorturl != "") { System.Windows.Forms.Clipboard.SetText(shorturl); historyMenu(shorturl); writeHistory(shorturl); urlnotif = shorturl; } else { System.Windows.Forms.Clipboard.SetText(linkFB); historyMenu(linkFB); writeHistory(linkFB); urlnotif = linkFB; } fallyToast.Toaster alertformfacebook = new fallyToast.Toaster(); alertformfacebook.Show("fallyGrab", "File has been uploaded to Facebook. The link has been copied to your clipboard.", 8, "Fade", "Up",linkFB,file); })); } }; string type = ""; if (Properties.Settings.Default.imageFormat == "JPG") type = "image/jpeg"; else if (Properties.Settings.Default.imageFormat == "PNG") type = "image/png"; dynamic parameters = new ExpandoObject(); parameters.message = ""; parameters.source = new FacebookMediaObject { ContentType = type, FileName = Path.GetFileName(file) }.SetValue(File.ReadAllBytes(file)); fb.PostAsync("me/photos", parameters); } else { fallyToast.Toaster alertformfb = new fallyToast.Toaster(); alertformfb.Show("fallyGrab", "You must login to Facebook from the settings panel", -1, "Fade", "Up", "", "", "error"); } } }
public void PostToWall() { string txt = "Arnavaaaaa"; var fb = new FacebookClient(_accessToken); fb.PostCompleted += (o, args) => { if (args.Error != null) { // Dispatcher.BeginInvoke(() => MessageBox.Show(args.Error.Message)); return; } // var result = (IDictionary<string, object>)args.GetResultData(); // _lastMessageId = (string)result["id"]; Dispatcher.BeginInvoke(() => { // MessageBox.Show("Message Posted successfully"); // text = string.Empty; // btnDeleteLastMessage.IsEnabled = true; }); }; var parameters = new Dictionary<string, object>(); parameters["message"] = txt; fb.PostAsync("me/feed", parameters); NavigationService.Navigate(new Uri("/panic_mode.xaml", UriKind.Relative)); }