BT

最新技術を追い求めるデベロッパのための情報コミュニティ

寄稿

Topics

地域を選ぶ

InfoQ ホームページ ニュース Google、YouTube、Facebookおよびその他Web 2.0 APIへのC#およびVB .NETライブラリ

Google、YouTube、Facebookおよびその他Web 2.0 APIへのC#およびVB .NETライブラリ

ブックマーク

Scott Hanselman氏による最近のブログの投稿(ブログ・英語)で、 Web全体に広まっているWeb 2.0 とのインターフェイスに有効な.NETライブラリのリストを編纂した。これらのサービスの利用方法の例を以下に紹介している。以下はリストからの抜粋である。

Digg

DiggのAPIはRESTと呼ばれ、通信にXMLを使用する。DiggApiNet(source)は、Digg APIの.NETラッパーである。Digg API.NET(source)CodeProjectで利用可能な別のラッパーである。Hanselman氏による以下の例では、指定されたURLから XmlDocumentが作成され、ロードされる。そしてXML ノードがDiggの特定のオブジェクトにコピーされる。

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は、複雑なAPI(source)を開発し、それに対する充実した.NETサポートがある。CodePlexは、 2つの関連プロジェクトをホストする。1つはFacebook.NET(source)であり、Facebookアプリケーションの開発やFacebook APIにアクセスする際に使用される.NET libraryを提供する。もう1つは、Facebook Developer Toolkit(source)であり、もともとClarity Consulting Inc.(サイト・英語)によって開発された。Jay Lagorio氏はVB.NETのFacebookラッパー(source)を記述し、fbasync(source)は、 Facebookの非同期APIに焦点を当てたCodePlexプロジェクトである。

GoogleおよびYouTube

GData(source)というGoogleのAPIは、HTTP上でXMLを使用して通信する一連のライブラリである。GDataは、 YouTube、Blogger、 Google Calendar、Notebook、Spreadsheets、Documents、Picassaなどで使用されている。Googleは.NETデベロッパにラッパー(source)を提供しているので、Google提供の.NET Developer's Guide(source)で紹介されている以下の例にあるように、かなり簡単にGDataコンテンツの読み書きができる。

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

詳細およびさまざまなWeb 2.0サービスで利用可能なライブラリについて詳しくは、Scott Hanselman氏による投稿(ブログ・英語)がよい開始点になる。

原文はこちらです: http://www.infoq.com/news/2008/04/Web20API

この記事に星をつける

おすすめ度
スタイル

BT