2010-10-31 98 views
3

我可以插入任何Google Reader API吗?我建立在PHP干净的RSS/Atom阅读器,并希望能得到所有从谷歌阅读器的好东西像饲料的历史,能够将注释添加到每个饲料项目等谷歌阅读器API?

回答

9

我已经建立了在python一些谷歌阅读器的集成,但我可以分享一些API知识,这样你就可以上手。 output = json也适用于所有。

登录:HTTPS www.google.com/accounts/ClientLogin

POST &电子邮件=电子邮件&的passwd =密码&服务=读者&源=应用程序的名字&继续= HTTP://www.google.com

从响应抓斗验证=

下一页击中:www.google.com/reader/api/0/token

HEADER金thorization =的GoogleLogin AUTH = $验证

这种反应变成$令牌会话。

从那里,它只是打了一些网址总是顺便指出AUTH头,它包括在查询字符串或交令牌。

获取您的订阅列表:www.google.com/reader/api/0/subscription/list?output=xml

要修改订阅,这是基本URL加上行动的一些数据后执行

www.google.com/reader/api/0/subscription/edit?pos=0 &客户= $源

POST添加性:s = $流&吨= $标题& T = $代币& ac =订阅

POST以除去性:s = $流& T = $令牌& AC =退订

的$流一般饲料/ $ feedurl像这样TechCrunch的,进料/ HTTP:// feeds.feedburner.com/Techcrunch

对不起不得不裂伤一些网址,因为我没有足够的代表呢。

+0

谢谢!我的PHP RSS客户端使用GR API似乎很“容易”。你有什么样的内置演示=) – 2010-11-06 22:15:13

+0

最好的例子是我在YouTube上发布的这个视频http://www.youtube.com/watch?v = UWnb7o0utfA – smilbandit 2010-11-07 03:22:59

+0

有没有方法使用API​​在Google阅读器中添加订阅? 谢谢! – PinoyStackOverflower 2012-01-06 16:21:06

0

谷歌阅读器对用户的反馈。我想你可以使用这些。另外,他们准备好了PubSubHubbub,所以你会在他们发生的时候得到评论/喜欢...。

此外,由于2013年7月1日,谷歌阅读器是没有更多的。替代选项包括Superfeedr

+0

Yupp,知道=)可是我的用户应该能够添加/修改/删除我的应用程序内的饲料,而饲料工作应该像谷歌读者可以评论,添加注释,分享等。 – 2010-10-31 15:20:02

2

这是Python中的工作示例:

import urllib, urllib2 
import json, pprint 

email, password = '[email protected]', 'nowayjose' 
clientapp, service = 'reader', 'reader' 

params = urllib.urlencode({'Email': email, 'Passwd': password, 'source': clientapp, 'service': service}) 
req = urllib2.Request(url='https://www.google.com/accounts/ClientLogin', data=params) 
f = urllib2.urlopen(req) 

for line in f.readlines(): 
    if line[0:5] == 'Auth=': 
    auth=line[5:] 

root = "http://www.google.com/reader/api/0/" 

req = urllib2.Request(root + "token") 
req.add_header('Authorization', 'GoogleLogin auth=' + auth) 
f = urllib2.urlopen(req) 
token = f.readlines()[0] 

# get user id 
req = urllib2.Request(root + "user-info?output=json&token="+token) 
req.add_header('Authorization', 'GoogleLogin auth=' + auth) 
f = urllib2.urlopen(req) 
dictUser = json.loads(f.read()) 
user_id = dictUser["userId"] 
print "user_id",user_id 

req = urllib2.Request(root + "subscription/list?output=json&token="+token) 
req.add_header('Authorization', 'GoogleLogin auth=' + auth) 
f = urllib2.urlopen(req) 

# for line in f.readlines(): 
#  print line 
dictSubscriptions = json.loads(f.read()) 

# pprint.pprint(dictSubscriptions) 
# print the first 3 subscription titles 
for i in dictSubscriptions["subscriptions"][0:2]: 
    print i["title"] 

req = urllib2.Request("http://www.google.com/reader/api/0/unread-count?output=json&token="+token) 
req.add_header('Authorization', 'GoogleLogin auth=' + auth) 
f = urllib2.urlopen(req) 
dictUnread = json.loads(f.read()) 
# pprint.pprint(dictUnread) 
# print the first 3 unread folders 
for i in dictUnread["unreadcounts"][0:3]: 
    print i["count"], i["id"] 

# this returns all starred items as xml 
req = urllib2.Request("http://www.google.com/reader/atom/user/"+user_id+"/state/com.google/starred?token="+token) 
req.add_header('Authorization', 'GoogleLogin auth=' + auth) 
f = urllib2.urlopen(req) 
starredItems = f.read()