谷歌阅读器API?

问题描述 投票:3回答:3

我可以插入任何Google Reader API吗?我用PHP构建了一个干净的RSS / Atom阅读器,并希望从Google阅读器中获取所有好东西,例如Feed的历史记录,能够为每个Feed项添加注释等。

rss google-reader atom-feed
3个回答
9
投票

我在python中构建了一些谷歌阅读器集成,但我可以分享一些api知识,这样你就可以开始了。输出= json也适用于所有人。

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

POST &email=email&passwd=password&service=reader&source=appname&continue=http://www.google.com

从响应抓取Auth =

下一步:www.google.com/reader/api/0/token

HEADER Authorization=GoogleLogin auth=$Auth

该响应成为会话的$ token。

从那里开始它只是命中一些url总是传递auth头并在查询字符串或帖子中包含令牌。

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

要修改订阅,这是基本URL以及要执行的操作的一些发布数据

www.google.com/reader/api/0/subscription/edit?pos=0&client=$source

POST添加:s=$streams&t=$title&T=$token&ac=subscribe

POST删除:s=$stream&T=$token&ac=unsubscribe

$ stream通常是feed / $ feedurl,适用于techcrunch,feed / http:// feeds.feedburner.com/Techcrunch

抱歉不得不破坏一些网址因为我还没有足够的代表。


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()

0
投票

Google阅读器为用户提供了Feed。我想你可以用那些。此外,他们准备好PubSubHubbub,所以你会得到评论/喜欢......一旦发生。

此外,截至2013年7月1日,谷歌阅读器已不复存在。替换选项包括Superfeedr

© www.soinside.com 2019 - 2024. All rights reserved.