BT

C# and VB .NET Libraries to Google, YouTube, Facebook, and other Web 2.0 APIs

| by Abel Avram Follow 9 Followers on Apr 03, 2008. Estimated reading time: 2 minutes |

In a recent post on his blog, Scott Hanselman has compiled a list of .NET libraries useful to interface with some of the Web 2.0 APIs that have proliferated all over the web. He also provides examples on how to access those services. This is an excerpt of his list.

Digg

Digg's API is called REST and uses XML for communication. DiggApiNet is a .NET wrapper for the Digg API. Digg API.NET is another wrapper available on CodeProject. In the following example written by Hanselman, an XmlDocument is created and loaded from a specified URL, then the XML nodes are copied into Digg specific objects.

private const string get_popular = "http://services.digg.com/stories/popular/comments/{0}";

public DiggComments GetPopular()
{
return GetPopular(new Hashtable());
}
public DiggComments GetPopular(Hashtable args)
{
string uri = String.Format(get_popular, HttpBuildUrl(args));
return new DiggComments(Request(uri));
}
public DiggComments(XmlDocument xml_doc) : base(xml_doc, "events")
{
_comments = new List();
if (xml_doc.SelectSingleNode("events") == null
|| xml_doc.SelectSingleNode("events").SelectNodes("comment") == null) {
throw new DiggApiException("XML response appears to be malformed, or contains unexpected data.");
}
foreach (XmlNode node in xml_doc.SelectSingleNode("events").SelectNodes("comment")) {
_comments.Add(new DiggComment(node));
}
}

Facebook

Facebook has developed a complex API, and there is plenty of .NET support for it. CodePlex hosts two related projects: Facebook.NET, which provides a .NET library for use in developing Facebook applications and accessing Facebook APIs, and Facebook Developer Toolkit which was initially developed by Clarity Consulting Inc.. Jay Lagorio has written a Facebook wrapper for VB.NET, and fbasync is a CodePlex project focused on asynchronous API for Facebook. 

Google and YouTube

Google's API, named GData, is a comprehensive set of libraries for communication using XML over HTTP. GData is serving YouTube, Blogger, Google Calendar, Notebook, Spreadsheets, Documents, Picassa, etc. Google has provided a wrapper for .NET developers, so they can read and write GData content quite easily, like in the following example provided by Google in the .NET Developer's Guide:

AtomEntry newPost = new AtomEntry();
newPost.Title.Text = "Marriage!";
newPost.Content = new AtomContent();
newPost.Content.Content = "<div xmlns='http://www.w3.org/1999/xhtml'>" +
"<p>Mr. Darcy has <em>proposed marriage</em> to me!</p>" +
"<p>He is the last man on earth I would ever desire to marry.</p>" +
"<p>Whatever shall I do?</p>" +
"</div>";
newPost.Content.Type = "xhtml";
newPost.Authors.Add(new AtomPerson());
newPost.Authors[0].Name = "Elizabeth Bennet";
newPost.Authors[0].Email = "liz@gmail.com";

AtomEntry createdEntry = service.Insert("http://www.blogger.com/feeds/" + blogId + "/posts/default", newPost);

For more information and many other libraries available for various Web 2.0 services, Scott Hanselman's post is a good starting point.

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT