
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 CosmosQuery 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 = "e6123aaaaaae92671bd110cf2a5e3b83";
// Get the freshest links to a target URL.
tech.CosmosType = "links";
// Cosmos lets you see what blogs are linking to a given URL.
// The query can return RSS or XML. This example uses RSS.
Tortuga.Rss rss = tech.CosmosQuery("http://www.boingboing.net/");
if (rss == null)
{
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);
int numInboundBlogs = channel.GetInt("tapi:inboundblogs");
listBox1.Items.Add("Num Inbound Blogs: " + Convert.ToString(numInboundBlogs));
int numInboundLinks = channel.GetInt("tapi:inboundlinks");
listBox1.Items.Add("Num Inbound Links: " + Convert.ToString(numInboundLinks));
// Iterate over the blogs linking to our target blog:
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("----");
}
// The RSS response is also available in the RawQueryResponse property.
textBox1.Text = tech.RawQueryResponse;
}