Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Reader API Unread Count

Does Google Reader have an API and if so, how can I get the count of the number of unread posts for a specific user knowing their username and password?

like image 879
GateKiller Avatar asked Sep 09 '08 20:09

GateKiller


1 Answers

This URL will give you a count of unread posts per feed. You can then iterate over the feeds and sum up the counts.

http://www.google.com/reader/api/0/unread-count?all=true

Here is a minimalist example in Python...parsing the xml/json and summing the counts is left as an exercise for the reader:

import urllib import urllib2  username = '[email protected]' password = '******'  # Authenticate to obtain SID auth_url = 'https://www.google.com/accounts/ClientLogin' auth_req_data = urllib.urlencode({'Email': username,                                   'Passwd': password,                                   'service': 'reader'}) auth_req = urllib2.Request(auth_url, data=auth_req_data) auth_resp = urllib2.urlopen(auth_req) auth_resp_content = auth_resp.read() auth_resp_dict = dict(x.split('=') for x in auth_resp_content.split('\n') if x) auth_token = auth_resp_dict["Auth"]  # Create a cookie in the header using the SID  header = {} header['Authorization'] = 'GoogleLogin auth=%s' % auth_token  reader_base_url = 'http://www.google.com/reader/api/0/unread-count?%s' reader_req_data = urllib.urlencode({'all': 'true',                                     'output': 'xml'}) reader_url = reader_base_url % (reader_req_data) reader_req = urllib2.Request(reader_url, None, header) reader_resp = urllib2.urlopen(reader_req) reader_resp_content = reader_resp.read()  print reader_resp_content 

And some additional links on the topic:

  • http://code.google.com/p/pyrfeed/wiki/GoogleReaderAPI
  • How do you access an authenticated Google App Engine service from a (non-web) python client?
  • http://blog.gpowered.net/2007/08/google-reader-api-functions.html
like image 172
jimmyorr Avatar answered Sep 28 '22 13:09

jimmyorr