QCon北京「鸿蒙专场」火热来袭!即刻报名,与创新同行~ 了解详情
写点什么

面向 Google、YouTube、Facebook 以及其他 Web 2.0 API 的 C#和 VB.NET 类库

  • 2008-04-08
  • 本文字数:1642 字

    阅读完需:约 5 分钟

在 Scott Hanselman 博客最近发表的一篇文章中,Scott 编辑了一系列.NET 类库,这些类库有助于开发人员面向那些互联网上著名的Web 2.0 API 进行开发。

Digg

Digg 的 API 使用 REST 形式的接口,并且通过 XML 进行通信。 DiggApiNet 是 Digg API 的一个.NET 封装。CodeProject 还包括另一个可用的 API 封装 Digg API.NET 。在 Hanselman 提供的如下示例中,从一个特定的 URL 中创建和加载了一个 XmlDocument 对象,然后将 XML 节点复制到 Digg 的特定对象中。

<pre id="pnnb">private const string get_popular = "http://services.digg.com/stories/popular/comments/{0}";<p>public DiggComments GetPopular()</p><br id="wtw-"></br>{ <br id="ekhu"></br> return GetPopular(new Hashtable());<br id="xo_v"></br>}<br id="fdxc"></br>public DiggComments GetPopular(Hashtable args)<br id="nq_t"></br>{ <br id="f0a1"></br> string uri = String.Format(get_popular, HttpBuildUrl(args)); <br id="f0yv"></br> return new DiggComments(Request(uri));<br id="v3vf"></br>}<br id="yteu"></br>public DiggComments(XmlDocument xml_doc) : base(xml_doc, "events")<br id="rafu"></br>{<br id="t4p3"></br> _comments = new List();<br id="rhjj"></br> if (xml_doc.SelectSingleNode("events") == null<br id="jcn9"></br> || xml_doc.SelectSingleNode("events").SelectNodes("comment") == null) {<br id="o1u6"></br> throw new DiggApiException("XML response appears to be malformed, or contains unexpected data.");<br id="h20r"></br> }<br id="qv17"></br> foreach (XmlNode node in xml_doc.SelectSingleNode("events").SelectNodes("comment")) {<br id="aung"></br> _comments.Add(new DiggComment(node));<br id="uhj6"></br> }<br id="ig1:"></br>}

Facebook

Fackbook 提供了一个复杂的API ,目前已经可以获得足够多的.NET 支持。CodePlex 托管了两个相关的项目:一个是 Facebook.NET ,它提供了一套用于开发 Facebook 应用程序以及访问 Fackbook API 的.NET 类库;另一个则是 Facebook Developer Toolkit ,最初由 Clarity Consulting Inc. 开发。Jay Lagorio 为 VB.NET 编写了一个 Facebook 的 API封装,而 fbasync 则是一个面向 Fackbook 异步 API 的 CodePlex 项目。

Google and YouTube

Google 的 API“ GData ” 是一套全面的类库,使用了 XML 并基于 HTTP 协议实现通信。GData 为 YouTube、Blogger、Google Calendar、Notebook、Spreadsheets、Documents、Picassa 等提供支持。Google 为.NET 开发人员提供了 一个封装,以便于他们快捷地读写 GData 内容。以下示例撷取自 Google 提供的.NET 开发人员指南

<pre id="e6mn">AtomEntry newPost = new AtomEntry();<br id="krk6"></br>newPost.Title.Text = "Marriage!";<br id="x311"></br>newPost.Content = new AtomContent();<br id="ewkz"></br>newPost.Content.Content = "<div xmlns='http://www.w3.org/1999/xhtml'>" +<br id="gu4j"></br> "<p>Mr. Darcy has <em>proposed marriage</em> to me!</p>" +<br id="rf9:"></br> "<p>He is the last man on earth I would ever desire to marry.</p>" +<br id="dtfd"></br> "<p>Whatever shall I do?</p>" +<br id="tt7j"></br> "</div>";<br id="cu93"></br>newPost.Content.Type = "xhtml";<br id="i77v"></br>newPost.Authors.Add(new AtomPerson());<br id="mc9i"></br>newPost.Authors[0].Name = "Elizabeth Bennet";<br id="lca7"></br>newPost.Authors[0].Email = "liz@gmail.com";<p>AtomEntry createdEntry = service.Insert("http://www.blogger.com/feeds/" + blogId + "/posts/default", newPost);</p>

如果您想了解更多有关各种 Web 2.0 服务的类库,从 Scott Hanselman 的文章出发会是一个不错的选择。

查看英文原文: C# and VB .NET Libraries to Google, YouTube, Facebook, and other Web 2.0 APIs

2008-04-08 23:551135
用户头像

发布了 157 篇内容, 共 57.0 次阅读, 收获喜欢 6 次。

关注

评论

发布
暂无评论
发现更多内容

DM运维踩坑实践总结

TiDB 社区干货传送门

Node_export端口变更

TiDB 社区干货传送门

TiDB 最佳实践

TiDB 社区干货传送门

TiDB监控实现--存活监控

TiDB 社区干货传送门

TiDB监控信息反向代理配置(一个域名可跳转不同集群)

TiDB 社区干货传送门

TiDB 拓扑查询工具qtidb

TiDB 社区干货传送门

TIDB备份引发公司所有TIDB集群不可用

TiDB 社区干货传送门

周五的暴击:TiKV 节点宕机无法正常启动之后

TiDB 社区干货传送门

开源OLAP引擎测评:Clickhouse vs TiDB vs Palo

TiDB 社区干货传送门

易果 TiDB 的使用以及数据中台的思考

TiDB 社区干货传送门

TiDB + HAProxy 配置透传 IP

TiDB 社区干货传送门

一个重大的突破领先于市场同类分布式DB产品

TiDB 社区干货传送门

TiDB-Lighting 迁移过程问题整理

TiDB 社区干货传送门

TiDB 3.0.1 与 3.0.2 版本的 TiKV 宕机对比测试

TiDB 社区干货传送门

热烈庆祝58同城TiDB All in v4.0.2(附核心PMC订单流水业务升级流程和一点使用感悟)

TiDB 社区干货传送门

TiDB 4.0 新 Feature 原理及实践系列合集

TiDB 社区干货传送门

TiDB 入门运维基础视频教程 (三) -- 导出工具 dumpling

TiDB 社区干货传送门

TiDB 3.0.2 版本某业务 TiKV 宕机测试

TiDB 社区干货传送门

隔离级别与锁 MySQL 篇

TiDB 社区干货传送门

补充 RECOVER 导致 TiDB Binlog 同步错误处理

TiDB 社区干货传送门

TiFlash运维漫谈

TiDB 社区干货传送门

TiDB 在车好多的实践

TiDB 社区干货传送门

TiDB 入门运维基础视频教程 (四) -- 导入工具 Lightning

TiDB 社区干货传送门

TiDB DM扩容和监控

TiDB 社区干货传送门

漫谈TiDB收费与成本

TiDB 社区干货传送门

原生K8s环境下 TiDB Operator实战

TiDB 社区干货传送门

TiKV 开发环境单机部署

TiDB 社区干货传送门

041-使用DM进行同步上游数据到 TiDB

TiDB 社区干货传送门

pd-recovery后部分tikv连接pd失败

TiDB 社区干货传送门

TiDB 3.0.2 手动指定 Drainer CommitTS

TiDB 社区干货传送门

TiDB 的正确使用姿势

TiDB 社区干货传送门

面向Google、YouTube、Facebook以及其他Web 2.0 API的C#和VB.NET类库_.NET_Abel Avram_InfoQ精选文章