public void PublishToMyWall() { try { attachment att = new attachment { name = "", href = "", caption = "has used the application", media = new List <attachment_media>() }; attachment_media_image attMEd = new attachment_media_image { src = "", href = "" }; att.media.Add(attMEd); action_link a = new action_link { text = "", href = "" }; IList <action_link> tempA = new List <action_link> { a }; fbService.Stream.PublishAsync(myWallTextBox.Text, att, tempA, null, 0, PublishAsyncCompleted, null); } catch (Exception) { } }
public void PublishToAFriendWall() { try { attachment att = new attachment { // Name of link name = "", // URL of link href = "", caption = "", media = new List <attachment_media>() }; attachment_media_image attMEd = new attachment_media_image { // Image source src = "", // URL to go to if clicked href = "" }; att.media.Add(attMEd); action_link a = new action_link { text = "What's this", //URL to go to if clicked href = "" }; IList <action_link> tempA = new List <action_link> { a }; // Use the typed friend UID to publish the typed message fbService.Stream.PublishAsync(friendWallTextBox.Text, att, tempA, uidTextBox.Text, 0, PublishAsyncCompleted, null); } catch (Exception) { } }
private void PostAppAddMessage(Api api, string profileid) { if (string.IsNullOrEmpty(profileid)) { Syslog.Write(new Exception("Cannot post to stream")); return; } var image = new attachment_media_image() { href = GeneralConstants.FACEBOOK_APP_URL, src = string.Format("{0}/Content/img/logo2.png", GeneralConstants.FACEBOOK_HOST), type = attachment_media_type.image }; var attachment = new attachment { media = new List <attachment_media>() { image }, caption = GeneralConstants.FACEBOOK_APP_URL, name = "tradelr for Facebook", href = GeneralConstants.FACEBOOK_APP_URL, description = "Display your products from tradelr.com on Facebook." }; try { api.Stream.Publish("added tradelr to my profile", attachment, null, null, long.Parse(profileid)); } catch (Exception ex) { Syslog.Write(ex); } }
public override void PostInserted(Post post) { // Send post to FaceBook try { ConnectSession session = new ConnectSession(ApiKey, AppSecret); session.SessionKey = SessionKey; if (session.IsConnected()) { Macros macros = new Macros(); Api api = new Api(session); string fullUrl = macros.FullUrl(post.Url); attachment attachment = new attachment(); attachment.name = post.Title; attachment.href = fullUrl; attachment.description = post.Excerpt("", "", "", 200); action_link link = new action_link(); link.href = fullUrl; link.text = "Read the full entry"; List <action_link> links = new List <action_link>(); links.Add(link); if (!String.IsNullOrEmpty(post.ImageUrl)) { attachment_media_image image = new attachment_media_image(); image.src = macros.FullUrl(post.ImageUrl); image.href = fullUrl; image.type = attachment_media_type.image; List <attachment_media> media = new List <attachment_media>(); media.Add(image); attachment.media = media; } foreach (long pageId in this.PageIdList) { try { api.Stream.Publish("", attachment, links, "", pageId); } catch (Exception ex) { Log.Error("Facebook Plugin", "Failed to submit status to Facebook. {0}", ex.Message); } } } else { Log.Error("Facebook Plugin", "Facebook Session ID not valid"); } } catch (Exception ex) { Log.Error("Facebook Plugin", "Failed to submit status to Facebook. {0}", ex.Message); } }