How to get popular tweets from twitter

In my earlier posts Daily twitter trends and Weekly twitter trends I showed how you can get daily and weekly twitter trends. That api gets you to queries that are being searched for. Next step in the process is to take those queries and get the messages posted related to those queries. Here is a simple method that combines results of trend api with search api to get popular messages on twitter.

static Dictionary<string, List<TwitterSearchStatus>> GetPopularTweets()
 List<TwitterSearchTrend> trends = GetDailyTrends();
 if (null == trends ||
     trends.Count == 0)
  return null;
 // For now only process first trend term.
 List<TwitterSearchStatus> searchResults = SearchForTerm(trends[0].Query);
 if (searchResults.Count == 0)
  return null;
 var resultsGrpByUser = from searchResult in searchResults
   group searchResult by searchResult.FromUserScreenName
   into userMessages
 select new { FromUser = userMessages.Key, Messages = userMessages };
 Dictionary<string, List<TwitterSearchStatus>> dict = 
  new Dictionary<string, List<TwitterSearchStatus>>();
 foreach(var userMessage in resultsGrpByUser)
  foreach(var twitterStatus in userMessage.Messages)
   Console.WriteLine("\t{0}", twitterStatus.Text);
  dict[userMessage.FromUser] = userMessage.Messages.ToList();
 return dict;




15.6 °C / 60.1 °F

weather conditions Clouds

Monthly Posts

Blog Tags