Google Reader, AJAX & Continuations

So I was mucking around with Niall's excellent reverse-engineering of the Google Reader, and I figured out that Google have some pretty must have some pretty funky (in a good way) framework to work with client/server interactions from Javascript.

The UI has a feature called the “Lens”, which allows one to scroll through blog posts. Posts are requested 20 at a time (and returned in an the Atom XML format). Once you scroll more than 20, another HTTP request is required. The usual way to do that would be to pass some kind of “start” parameter, but instead the Atom file contains a <gr:continuation> element which contains a unique ID (think of it as a session ID).

This id can be passed to the Google feed URL endpoint, and it will return the next 20 elements starting from where you left off.

EG:

1) request: GET /reader/atom/feed/http%3A%2F%2Fdel.icio.us%2Frss%2Fpopular%2F

2) response:
<feed>...<gr:continuation>COT3ruq0jYIC</gr:continuation>...</feed>


3) request: GET /reader/atom/feed/http%3A%2F%2Fdel.icio.us%2Frss%2Fpopular%2F?c=COT3ruq0jYIC

4) response: Contains the next 20 elements

I'd really love to see the framework that is doing this stuff.

More realistically, I'd like to know the best way to only show unread items for a specific feed. I know I can grab the feed for each label, then for the feed, and loop over the feed entries looking for ones marked as read in the label feed, but there are a number of problems with that and it seems like there should be a better way. Any clues Chris?

Hopefully there's a way to do that so I can fix the things I don't like about Google Reader myself.

Leave a Reply

Your email address will not be published. Required fields are marked *