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)
{
Console.WriteLine(userMessage.FromUser);
foreach(var twitterStatus in userMessage.Messages)
{
Console.WriteLine("\t{0}", twitterStatus.Text);
}
dict[userMessage.FromUser] = userMessage.Messages.ToList();
Console.WriteLine("*************");
}
return dict;
}
Get popular tweets from twitter
How to plan CCSP Exam preparation
Develop a MongoDB pipeline to transform data into time buckets
Alert and Confirm pop up using BootBox in AngularJS
AngularJS Grouped Bar Chart and Line Chart using D3
How to lock and unlock account in Asp.Net Identity provider
2025 © Byteblocks, ALL Rights Reserved. Privacy Policy | Terms of Use