谷歌阅读器API未读计数 [英] Google Reader API Unread Count

查看:130
本文介绍了谷歌阅读器API未读计数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谷歌阅读器是否有一个API,如果是这样,我怎么能得到一个特定的用户未读的职位数的计数知道自己的用户名和密码?

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?

推荐答案

此网址会给你每饲料未读帖子的计数。然后,您可以遍历饲料和总结计数。

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

<一个href=\"http://www.google.com/reader/api/0/unread-count?all=true\">http://www.google.com/reader/api/0/unread-count?all=true

下面是Python中的极简主义的例子...解析XML / JSON和总结的计数就留给读者做练习:

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 = 'username@gmail.com'
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

这篇关于谷歌阅读器API未读计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆