public TwitterTimelineResponse GetRecentTweets(int blogId) { TwitterTimelineResponse latestTweets = default(TwitterTimelineResponse); try { var blogHome = Umbraco.TypedContent(blogId); if (blogHome != null) { var twitterAccount = blogHome.HasProperty("authenticatedTwitterAccount") && blogHome.HasValue("authenticatedTwitterAccount") ? blogHome.GetPropertyValue <TwitterOAuthData>("authenticatedTwitterAccount") : default(TwitterOAuthData); if (twitterAccount != null) { //get twitter service using authenticated twitter details Skybrud.Social.Twitter.TwitterService service = twitterAccount.GetService(); //get last 5 tweets latestTweets = service.Statuses.GetUserTimeline(twitterAccount.ScreenName, 5); } } } catch (Exception ex) { LogHelper.Error(typeof(TweetThisApiController), "Error Retrieving Timeline", ex); } return(latestTweets); }
public static TwitterService CreateFromOAuthClient(TwitterOAuthClient client) { // This should never be null if (client == null) throw new ArgumentNullException("client"); // Initialize the service TwitterService service = new TwitterService { Client = client }; // Set the endpoints etc. service.Account = new TwitterAccountEndpoint(service); service.Favorites = new TwitterFavoritesEndpoint(service); service.Followers = new TwitterFollowersEndpoint(service); service.Friends = new TwitterFriendsEndpoint(service); service.Geo = new TwitterGeoEndpoint(service); service.Lists = new TwitterListsEndpoint(service); service.Search = new TwitterSearchEndpoint(service); service.Statuses = new TwitterStatusesEndpoint(service); service.Users = new TwitterUsersEndpoint(service); // Return the service return service; }
/// <summary> /// Initializes a new instance of the TwitterService class. Invoking this method will not /// result in any calls to the Twitter API. /// </summary> public TwitterService GetService() { return _service ?? (_service = TwitterService.CreateFromOAuthClient(new TwitterOAuthClient { ConsumerKey = ConsumerKey, ConsumerSecret = ConsumerSecret, Token = AccessToken, TokenSecret = AccessTokenSecret })); }