How get weekly twitter trends using REST API

by Viper 22. May 2009 14:50

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;
}

 

Views: 4919

Tags: ,

Twitter

blog comments powered by Disqus

Smart Phones Poll

What smart phone do you currently own?





Show Results

Month List

Powered by BlogEngine.NET 2.0.0.49
Theme by Naveen Kohli