返回正常中文阅读

金牌译作 Google Reader API

1895个读者 翻译: deng  04/12/2008 原文 引用 双语对照及眉批

删除:
把眉批拖到这里

Google Reader is an online feed aggregator with heavy use of JavaScript and pretty quick loading of the latest feed data from around the web. Google’s AJAX front-end styles back-end data published in the Atom syndication format. The data technologies powering Google Reader can easily be used and extended by third-party feed aggregators for use in their own applications. I will walk you through the (previously) undocumented Google Reader API.

Update 10:40 p.m.:Jason Shellen, PM of Google Reader, called me to let me know that Google built its feed API first and the Google Reader application second as a demonstration of what could be done with the underlying data. Jason confirmed my documentation below is very accurate and Google plans to release a feed API "soon" and perhaps within the next month! Google Reader engineer Chris Wetherell has also confirmed the API in the comments below.

A reliable feed parser managed by a third party lowers the barrier to entry of new aggregator developers. Google and its team of engineers and server clusters can handle the hard work of understanding feeds in various formats and states of validation, allowing developers to focus on the interaction experience and other differentiating features. You can also retrieve and synchronize feed subscription lists with an established user base that could be in the millions, providing a better experience for users on multiple devices and platforms. Google Reader’s "lens" provides only one view of the available data.

Google Reader users are assigned a 20-digit user ID used throughout Google’s feed system. User-specifc data is accessible using the google.com cookie named "SID."

Feed retrieval

/reader/atom/feed/

Google converts all feed data to Atom regardless of its original publication format. All RSS feed post content appears in the summary element and unlike the My Yahoo! backend I found no additional metadata about the feed containing full posts but Google does publish content data where available.

You may request any feed from the Google Reader system using the following URL structure:

You may specify the total number of feed entries to retrieve using the n parameter. The default number of feed items returned is 20 (n=20).

Google strips off all the data it does not render in Reader. Stripped data includes namespaced data such as Apple iTunes podcast data and Yahoo! Media RSS, additional author data such as e-mail and home URL, and even copyright data.

Subscription list

/reader/atom/user/[user id]/pref/com.google/subscriptions

Google Reader’s feed subscription list contains a user’s current feed subscriptions as well as past deleted subscriptions. Each feed is contained in an entry complete with feed URL, published and updated dates, and user-specific tags, if present. Current subscriptions are categorized as a reading list state. You may request the full list of feeds by setting the complete to true.

Here is a copy of my Google Reader subscription list with my user ID zeroed out. I am not subscribed to my RSS feed (index.xml) and I have added tags to my Atom feed. Each listed feed contains an author element which appears to be empty regardless of declarations within the original feed. Perhaps Google plans to add some feed claiming services, but its own Google blog has no affiliated author information.

Reading list

/reader/atom/user[user id]/state/com.google/reading-list

My favorite feature of the Google Reader backend is direct access to a stream of unread entries across all subscribed feeds. Google will output the latest in a "river of news" style data view.

Here is a sample from my limited subscription set. You may specify the total number of entries you would like Google to return using the n parameter -- the default is 20 (n=20).

Read items only

http://www.google.com/reader/atom/user/[user ID]/state/com.google/read

You can retrieve a listing of read items from Google Reader. You might want to analyze the last 100 items a user has read to pull out trends or enable complete search and this function may therefore be useful. You may adjust the number of items retrieved using the n parameter -- the default is 20 (n=20).

Reading list by tag

/reader/atom/user/[user id]/label/[tag]

You may also view a list of recently published entries limited to feeds of a certain tag. If you have tagged multiple feeds as "marketing" you might want to request just the latest river of news for those marketing feeds. The returned feed contains both read and unread items. Read items are categorized as read (state/com.google/read) if you would like to hide them from view. The number of returned results may be adjusted using the n parameter.

Starred items only

/reader/atom/user[user id]/state/com.google/starred

Google Reader users can flag an item with a star. These flagged items are exposed as a list of entries with feed URL, tags, and published/updated times included. You may specify the total number of tagged entries to return using the n parameter -- the default value is 20 (n=20).

Google treats starred items as a special type of tag and the output therefore matches the tag reading list.

Add or delete subscriptions

/reader/api/0/edit-subscription

You may add any feed to your Google Reader list using the Google Reader API via a HTTP post.

  • /reader/api/0/edit-subscription -- base URL
  • ac=["subscribe" or "unsubscribe"] -- requested action
  • s=feed%2F[feed URL] -- your requested subscription
  • T=[command token] -- expiring token issued by Google. Obtain your token at /reader/api/0/token.

Add tags

/reader/api/0/edit-tag

You may also add tags to any feed or individual item via a HTTP post.

  • /reader/api/0/edit-tag -- base URL
  • s=feed%2F[feed URL] -- the feed URL you would like to tag
  • i=[item id] -- the item ID presented in the feed. Optional and used to tag individual items.
  • a=user%2F[user ID]%2Flabel%2F[tag] -- requested action. add a tag to the feed, item, or both.
  • a=user%2F[user ID]%2Fstate%2Fcom.google%2Fstarred -- flag or star a post.
  • T=[special scramble] -- three pieces of information about the user to associate with the new tag. Security unknown and therefore unpublished.

Conclusion

It is possible to build a your own feed reader on top of Google'sdata with targeted server calls. You can power an application both online and offline using Google as your backend and focus on building new experiences on top of the data. Advanced functionality is available with a numeric Google ID and some variable tweaks.

Google has built the first application on top of this data API, the Google Reader lens, and judging from their choice of URLs the lens may not be Google's last application built on this data set. I like the openness of the data calls and think the Google Reader APIs are simple enough to bootstrap a few new applications within Google or created by third-party developers.

Google Reader 是一个使用了大量JavaScript构建的feed聚合器,它能非常及时地抓取最新的feed数据。Google的Ajax前台调用到的数据采用了Atom格式,这种数据技术降低了Google Reader的开发难度,同时也使得第三方应用很容易对其进行扩展。接下来我将带你提前预览Google Reader API

晚上10:40更新:Google Reader的产品经理Jason Shellen告诉我Google是先建立feed的API,然后才在这些数据之上建立的程序,这无疑是一个如何利用这些数据的典范。Jason肯定了我接下来这些文档的准确性,而且宣称Google计划“很快”(有可能是一个月内)将发布一个关于feed的API。同时,Google Reader的工程师Chris Wetherell也确认了这些说法

对新的聚合器开发者来说,由第三方提供的稳定可靠的feed解析服务能有效地降低其入门难度。Google和他们的工程师、服务器集群能够处理各种不同格式和验证状态的feed,使得开发者能把精力集中到交互体验和其他功能上来。你可以建立基于大量用户的应用,获取和同步他们的feed订阅列表,并且给用户提供基于不同设备和平台的更好体验。Google Reader本身只是给这些有用的数据提供了一种视图而已。

Google Reader对使用其feed系统的用户分配了20位数字构成的用户ID,用户各种数据的获取,都需要利用到domain为google.com下的名叫SID的cookie字段。

Feed获取

/reader/atom/feed/

不管feed一开始采用了什么格式,Google都将其转化为Atom格式。所有的RSS feed包含一切在提要里边出现的所有元素,这一点和My Yahoo! backend不一样,Yahoo的不包含任何附加的元数据。

你可以一下的格式从Google Reader访问任何feed:

你可以通过参数n设置返回的文章数量,默认为20。

Google忽略掉在阅读器里边没有用的数据,它们包括命名空间(如Apple iTunes podcast、Yahoo! Media RSS的命名空间)、作者信息(如email、主页地址等)、甚至于版权等内容。

订阅列表

/reader/atom/user/[user id]/pref/com.google/subscriptions

Google Reader的feed订阅列表包含用户当前订阅的和已经被删除的订阅。每个feed包含其地址、发布和更新时间、用户标记的标签(如果有的话)。当前订阅都被归类到阅读列表状态。通过设置complete为true,你还可以获取到所有的feed列表。

这里是我在Google Reader用户ID全部为0的账户的订阅列表。我没有订阅我自己的RSS feed,不过给我的Atom feed打上了标签。不管在原feed里边是否声明了作者,在每个列出的feed包含author元素都是空的。也许Google计划增加feed的认领服务,不过即使是他们自己的Google Blog,也还是没有任何额外的作者信息。

阅读列表

/reader/atom/user[user id]/state/com.google/reading-list

我最喜欢Google Reader的阅读列表功能,它能直接访问到我订阅feed中所有未读的文章,以一种“新闻流”的方式展现它们。

这里有一个我的阅读列表的例子,你同样可以通过参数n设置返回文章的数量。

已阅读文章

http://www.google.com/reader/atom/user/[user ID]/state/com.google/read

你可以通过这个API获取到用户在Google Reader里边已读的文章。如果想通过用户最近阅读的100篇文章分析其趋势或者实现对它们的查询,那么这个功能就很有用了。参数n同样可以设置返回的文章数量。

某标签下的文章列表

/reader/atom/user/[user id]/label/[tag]

你还可以查看指定标签下最近发表的文章。比如你把很多feed标记为“营销”,只是想访问有关营销的feed,这就很有用了。返回的内容中包含已读和未读的文章。已读的文章被归类到已读(state/com.google/read),你可以通过这判断是否将它们隐藏起来。返回的数量可以通过参数n来判断。

标星文章

/reader/atom/user[user id]/state/com.google/starred

Google Reader允许用户对文章标星。这些标星文章包括有feed地址、标签、发布/更新时间。你可以通过参数n指定返回的数量,默认为20。

Google将标星项目视作一种特殊的标签,因此输出的内容和标签下文章列表结构一致。

添加或删除订阅

/reader/api/0/edit-subscription

使用POST请求访问Google Reader的API,你可以添加任何feed到Google Reader的订阅列表。

  • /reader/api/0/edit-subscription -- 基本地址
  • ac=["subscribe" 或者 "unsubscribe"] -- 请求动作
  • s=feed%2F[feed URL] -- 请求的订阅
  • T=[命令标识] -- Google发布的具有时效性的标识,可以通过/reader/api/0/token获取。

添加标签

/reader/api/0/edit-tag

通过HTTP的POST请求可以给一个feed或单独的文章打上标签。

  • /reader/api/0/edit-tag -- 基本地址
  • s=feed%2F[feed URL] -- 你想打标签的feed地址
  • i=[item id] -- 出现在feed中的文章的id,可选,用来给个别的文章打标签。
  • a=user%2F[user ID]%2Flabel%2F[标签] -- 请求动作,添加标签给feed,文章,或者两者。
  • a=user%2F[user ID]%2Fstate%2Fcom.google%2Fstarred -- 标星文章。
  • T=[special scramble] -- 关于用户和新标签的信息。可能处于安全因素考虑,尚未公开。

总结

基于对Google上面这些和县官服务的请求,你有可能构建自己的feed阅读器。你可以把Google作为你的后台,创建具有全新体验的在线和离线的程序,利用Google的ID,略施小计,你还可以创建更加高级的功能。

Google已经在这些数据API之上建立了第一个程序——Google Reader,从他们对API地址的选择之上来看的话,Google Reader应该不是最后一个基于这些数据集的程序。我喜欢数据调用的开放,Google Reader 的API是如此简单,相信会引导Google和第三方开发者创建更多的新应用!


继续阅读
  • 2006 年互联网技术发展趋势

    已经十二月了,是该回顾一下2006年互联网技术的发展状况,和展望2007年的时候了。在随后的几周,Read/WriteWeb将发表一系列深度分析2006年出现的产品和趋势的文章。同时我们会畅想一下20...

  • 被否决的Google Logo

    优胜劣汰,Google Logo也不例外。幸福的Logo是一样的,不幸的Logo各有各的不幸······

  • Facebook如何击败Myspace,Yahoo!和Google?

    Facebook如何击溃Myspace,Yahoo!和Google? 原文作者:Christopher Beam (Slate.com在线杂志专栏作家) 每个年轻人——通常刚脱稚气——必须作出一个重...

  • Google 的疯狂面试题

    几星期前,一个朋友接受了Google公司的面试,他透露了面试中的一些问题。顺便,我把从其他几个曾经面试过的人那里听来的内容也整理在一起。最大的互联网公司Google的一份面试题集,看看你是否能够回答出...

  • 聪明地使用Google的7个技巧

    我在下面编辑了一份包含7个使用Google的技巧的清单,我相信每个人都会想要知道这些.我认为这些技巧合在一起已经代表了使用Google搜索的所有技巧和方法的最高成就.虽然除此之外还有很多小技巧,但这7...

  • 三条提高gmail工作效率的可靠忠告

    如果你是个技术专家,email是必不可少的,但要完全控制所有电邮会很困难。如果你使用gmail和firefox,这里有一些技巧可以帮你如意掌控所有电邮。 第一个技巧是补救措施:把所有邮件保存在邮箱之...

  • 深究:发掘Google Reader的功能

    Google Reader 是一款功能庞大的RSS 阅读器,不过如果你没有仔细研究它的文档,那么你很可能并未充分利用它提供的功能。 今天我将通过介绍Google Reader丰富的快捷键来展示Goo...

  • Google办公室(总部)照片——世界各国的Google总部

    Google办公室(总部)——位于世界各国的照片...这是做梦都想去工作的地方呀:)

相关小组

标签:

内容有问题?请与我们联络。

译作评分

  • Currently 0.00/5
  • 1
  • 2
  • 3
  • 4
  • 5
 0.0  |  0 个评分