How get weekly twitter trends using REST API

This code sample will show how you can get weekly trends using REST API. The sample shows another feature of the API where you can specify a criteria to limit the results. You can specify a start date for the report. This is set by calling On method on ITwitterSearchTrends.


static List GetWeeklyTrends(DateTime ? onDate)
{
 TwitterClientInfo clientInfo = new TwitterClientInfo();
 clientInfo.ClientName = "Marketweet";
 clientInfo.ClientUrl = "http://www.byteblocks.com";
 clientInfo.ClientVersion = "1.1";
 List trendNames = new List();
 IFluentTwitter ft = FluentTwitter.CreateRequest(clientInfo);
 ft.AuthenticateAs(LOGIN_NAME, PASSWORD);
 ITwitterSearchTrends searchTrends = ft.Search().Trends().Weekly();
 if (null != onDate)
 {
  searchTrends.On(onDate.Value).AsJson();
 }
 var resp = ft.Request();
 if (null != resp)
 {
  var trends = resp.AsTrends();
  if (null != trends)
  {
   foreach (TwitterSearchTrend trend in trends.Trends)
   {
    trendNames.Add(trend.Name);
   }
  }
 }
 return trendNames;
}

Search

Social

Weather

16.6 °C / 61.8 °F

weather conditions Clear

Monthly Posts

Blog Tags