Sal
Peter Hoffmann Director Data Engineering at Blue Yonder. Python Developer, Conference Speaker, Mountaineer

Atom feed for Google Reader liked items

While you can make your Google Reader starred and shared items public available, I found no way to do the same for my liked items. There isn't even a link from inside Google Reader to view your liked items.

But you can view your liked items if you open the following url http://www.google.com/reader/view/user/-/state/com.google/like. And there is even an Atom feed available http://www.google.com/reader/atom/user/-/state/com.google/like. The problem is that you have to be logged in to view the feed. So here is a small script to do a Google ClientLogin and dump the atom feed.

import httplib2
from urllib import urlencode
client = httplib2.Http('cache')

def request_auth_token(email, passwd):
    """request auth token from google

    see: http://code.google.com/apis/accounts/
         http://code.google.com/apis/accounts/docs/AuthForInstalledApps.html
    """
    url = 'https://www.google.com/accounts/ClientLogin'
    headers = {'Content-type': 'application/x-www-form-urlencoded'}
    body = urlencode({'Email': email, 'Passwd': passwd, 'service': 'reader'})
    response, content = client.request(url, 'POST', headers=headers,  body=body)
    assert response['status'] == '200'
    #if status == 403 check for Error=CaptchaRequired
    resp_data = dict(x.split('=') for x in content.split('\n') if x)
    return resp_data["Auth"]

def likes_feed(auth):
    url = "http://www.google.com/reader/atom/user/-/state/com.google/like"
    headers = {'Authorization': 'GoogleLogin auth=%s' % auth}
    response, content = client.request(url, 'GET', headers=headers)
    return content


if __name__ == '__main__':
    email = "XXX@gmail.com"
    passwd = "XXX"
    auth  = request_auth_token(email, passwd)
    print likes_feed(auth)

The same method should work to get the content of private folders in Google Reader.