public static List <TweetDisplay> GetTweets(string searchCriteria) { // initialise a Credentials object with the keys supplied by the twitter api registration var credentials = CredentialsCreator.GenerateApplicationCredentials(consumerKey, consumerSecret); // tell twitter our credentials TwitterCredentials.SetCredentials(credentials.AuthorizationKey, credentials.AuthorizationSecret, credentials.ConsumerKey, credentials.ConsumerSecret); // Search the tweets containing the search criteria and create a list to display in the view, only use top 4 var items = Search.SearchTweets(searchCriteria).OrderByDescending(a => a.CreatedAt).ToList().Take(4); // create an empty list var results = new List <TweetDisplay>(); // Make a list of tweet items for using in the view foreach (var item in items) { var td = new TweetDisplay { CreatedAt = item.CreatedAt, Author = item.Creator.Name, Tweet = item.Text, ImageUrl = item.Creator.ProfileImageUrl }; results.Add(td); } return(results); }
public async Task <PageResult> OnGetAsync() { MyService Twitter = new MyService(); tweetDisplay = await Twitter.GetTweetAsync(); return(Page()); }
/// <summary> /// The add tweet. /// </summary> /// <param name="t"> /// The t. /// </param> public void AddTweet(TweetDisplay t) { if (this.FlowLayoutPanel != null) { this.FlowLayoutPanel.Controls.Add(t); // move it to the top this.FlowLayoutPanel.Controls.SetChildIndex(t, 0); } }