Monday, March 24, 2008

Creating a HTML “friends” page from a Google Reader subscription list

Google’s Social Graph API crawls the web and extracts publicly available relationship data (edges) for people on various public pages marked up with XFN or FOAF metadata (nodes). Like many others, I have accounts on Twitter, Flickr, FriendFeed, etc., which are all great sources to crawl for social graph edge relationships, but a number of interesting relationships were still hidden inside my private Google Reader subscription list.


This short guide demonstrates how I extract that information and publish it publicly via plain HTML decorated with XFN markup. (See an example.)



The process involves using Google Reader to manage your blogroll to 1) give a common label to the people whose blogs you read, 2) name those subscriptions appropriately, 3) share those subscriptions publicly, 4) find your public user id, and finally, 5) write a script that reads the subscription list and republishes it as HTML on your own site.



Step One: Using the “Manage Subscriptions »” link at the bottom of the left-hand panel in Google Reader, create a new folder called “people”. You can call this “friends”, “blogroll”, whatever — the important thing is that this label is used to tag every personal blog you want in your public blogroll. Note that these are blogs written by individual people, not collections of people.



Step Two: Next, go back over each of these subscriptions and use the “Rename” button to set the name of the blog to be the name of the author. Some blog feeds are already published this way by their author. Others, such as John Gruber’s Daring Fireball, set the blog title to the name of the site, not the person. In those cases, go back and rename the feed “John Gruber”, or whatever.




Step Three: Using the “Settings > Tags” menu, find your new “people” label and toggle the “private” sharing status to “public”. Doing so will reveal a number of new features, such as “view public page”, “email a link”, “add a clip to your site”, and “add a blogroll to your site”. These are all interesting features, and something you might want to explore more fully later, but in our case we’re doing something a little different.




Step Four: On the same “Settings > Tag” screen, look at the URL for the “view public page” link. It should read something like:


http://www.google.com/reader/shared/user/16671002588179970970/label/people


That 20 digit number is your public id. Jot this down — you’ll need this for the next step.



Step Five: This is the hardest part, in that it involves a bit of programming (or the ability to cut and paste and modify python code), and a server that you can run scripts on.


In this example, we’ll be using a python script to take the JSON-formatted output provided by Google Reader to build a data structure composed of dicts and sequences with the help of the simplejson library, and subsequently using Django templates to render this data as HTML.

No comments: