
C# sample code using "Tortugati", a .NET class library for the Technorati API.
The Tortuga .NET Component (Beta) can be downloaded from
Tortuga .NET Component
The download contains an .NET class library (DLL) that needs to be referenced from your C# or VB.NET project.
// Technorati SearchQuery C# Example Source Code
Tortuga.Technorati tech = new Tortuga.Technorati();
// An API key is required. You can get the Technorati API Key
// from http://www.technorati.com/developers/
tech.Key = "e6123d11111192671bd110cf2a5e3b83";
// Find blogs about nanotechnology
// When using more than one search term, separate the terms
// with spaces. For example: "blog software"
Tortuga.Rss rss = tech.SearchQuery("nanotechnology");
if (rss == null)
{
// Display the error returned by Technorati.
MessageBox.Show(tech.RawQueryResponse);
}
else
{
// Success! Let's get some information...
// The RSS response always has a single channel. The information will
// be contained within the channel.
Tortuga.Rss channel = rss.GetChannel(0);
// Iterate over the search results:
int i;
for (i=0; i<channel.NumItems; i++)
{
Tortuga.Rss item = channel.GetItem(i);
string blogTitle = item.GetString("title");
string blogUrl = item.GetString("link");
listBox1.Items.Add(blogTitle);
listBox1.Items.Add(blogUrl);
listBox1.Items.Add("----");
// There are many other field you could retrieve for each search result:
string description = item.GetString("description");
DateTime created = item.GetDate("tapi:created");
int numInboundBlogs = item.GetInt("tapi:inboundblogs");
int numInboundLinks = item.GetInt("tapi:inboundlinks");
string atomUrl = item.GetString("tapi:atomurl");
string rssUrl = item.GetString("tapi:rssurl");
}
// The RSS response is also available in the RawQueryResponse property.
// Be sure to have a look at the response so you can see what other information
// might be available.
textBox1.Text = tech.RawQueryResponse;
}