by Viper
22. May 2009 04:44
This code snippet shows you how you can get twitter daily trends using TweetSharp API. It is very important that you get latest code for the API. There was a bug in Trend API that I discovered and got fixed from the developers of the API.
static void GetDailyTrends()
{
IFluentTwitter ft = FluentTwitter.CreateRequest();
ft.AuthenticateAs(LOGIN_NAME, PASSWORD);
ft.Search().Trends().Daily().AsJson();
var resp = ft.Request();
if (null != resp)
{
var trends = resp.AsTrends();
if (null != trends)
{
foreach (TwitterSearchTrend trend in trends.Trends)
{
Console.WriteLine("Query: {0}\tName: {1}",
trend.Query.PadRight(40), trend.Name);
}
}
}
}
Outpt of this console application looks like below.
Query: "American Idol" OR #idol Name: American Idol
Query: Cavs Name: Cavs
Query: "Kris Allen" Name: Kris Allen
Query: "Adam Lambert" OR Lambert Name: Adam Lambert
Query: LeBron Name: LeBron
Query: Cleveland Name: Cleveland
Query: Kobe Name: Kobe
Query: Kiss Name: Kiss
Query: NBA Name: NBA
Query: #americanidol Name: #americanidol
Query: "Rashard Lewis" Name: Rashard Lewis
Query: "Top Echelon Network" Name: Top Echelon Network
Query: "Go Magic" OR Magic Name: Go Magic
Query: Glee Name: Glee
Query: "Star Trek" Name: Star Trek
Query: Lakers Name: Lakers
Query: Adam's Name: Adam's
Query: "Terminator Salvation" Name: Terminator Salvation
Query: Goodnight Name: Goodnight
Query: Queen Name: Queen