/// <summary> /// Gets and updates a tweet /// </summary> private bool GetAndUpdateTwitterPost() { // Get the channel the tweet is tied to TwitterAccountInfo channel = TwitterAccountInfoProvider.GetTwitterAccountInfo("MyNewTwitterChannel", SiteContext.CurrentSiteID); if (channel == null) { throw new Exception("[ApiExamples.GetAndUpdateTwitterPost]: Account 'MyNewTwitterChannel' has not been found."); } // Get a post tied to the channel TwitterPostInfo tweet = TwitterPostInfoProvider.GetTwitterPostInfoByAccountId(channel.TwitterAccountID).FirstOrDefault(); if (tweet == null) { throw new Exception("[ApiExamples.GetAndUpdateTwitterPost]: No post has been created via these api-examples. (There is no post tied to 'MyNewTwitterChannel'.)"); } // Update the properties tweet.TwitterPostText = tweet.TwitterPostText + " Edited."; // Save the changes into DB TwitterPostInfoProvider.SetTwitterPostInfo(tweet); return(true); }
/// <summary> /// Deletes all tweets tied to channel 'MyNewTwitterChannel'. /// </summary> private bool DeleteTwitterPosts() { // Get the channel the tweet is tied to TwitterAccountInfo channel = TwitterAccountInfoProvider.GetTwitterAccountInfo("MyNewTwitterChannel", SiteContext.CurrentSiteID); if (channel == null) { throw new Exception("[ApiExamples.DeleteTwitterPosts]: Account 'MyNewTwitterChannel' has not been found."); } // Get all posts tied to the account ObjectQuery <TwitterPostInfo> tweets = TwitterPostInfoProvider.GetTwitterPostInfoByAccountId(channel.TwitterAccountID); // Delete these posts from CMS and from Twitter foreach (TwitterPostInfo tweet in tweets) { TwitterPostInfoProvider.DeleteTwitterPostInfo(tweet); } return(tweets.Count != 0); }
/// <summary> /// Publishes a tweet. /// </summary> private bool PublishTweetToTwitter() { // Get the channel the tweet is tied to TwitterAccountInfo channel = TwitterAccountInfoProvider.GetTwitterAccountInfo("MyNewTwitterChannel", SiteContext.CurrentSiteID); if (channel == null) { throw new Exception("[ApiExamples.PublishTweetToTwitter]: Account 'MyNewTwitterChannel' has not been found."); } // Get a post tied to the channel TwitterPostInfo tweet = TwitterPostInfoProvider.GetTwitterPostInfoByAccountId(channel.TwitterAccountID).FirstOrDefault(); if (tweet == null) { throw new Exception("[ApiExamples.PublishTweetToTwitter]: No post has been created via these api-examples. (There is no post tied to 'MyNewTwitterChannel'.)"); } // Publish the post. The Tweet is scheduled for publishing if its FacebookPostScheduledPublishDateTime is set in the future. TwitterPostInfoProvider.PublishTwitterPost(tweet.TwitterPostID); return(true); }