プラグインできる Google Reader API はありますか? PHP でクリーンな RSS/Atom リーダーを作成しています。Google リーダーから、フィードの履歴や、各フィード アイテムにコメントを追加できる機能などをすべて取得したいと考えています。
3 に答える
Python で Google リーダーの統合を構築しましたが、API の知識の一部を共有して、開始できるようにします。output=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 にヒットし、常にその認証ヘッダーを渡し、クエリ文字列または投稿にトークンを含めます。
サブスクリプションのリストを取得します: www.google.com/reader/api/0/subscription/list?output=xml
サブスクリプションを変更するには、これはベース URL と、アクションを実行するためのいくつかの投稿データです。
www.google.com/reader/api/0/subscription/edit?pos=0&client=$source
追加する投稿:s=$streams&t=$title&T=$token&ac=subscribe
削除する投稿:s=$stream&T=$token&ac=unsubscribe
$stream は通常、techcrunch の場合、feed/http://feeds.feedburner.com/Techcrunch のように feed/$feedurl です。
申し訳ありませんが、私はまだ十分な担当者を持っていないため、いくつかの URL を台無しにしなければなりませんでした。
これは python での実際の例です:
import urllib, urllib2
import json, pprint
email, password = 'jose@gmail.com', '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()
Google リーダーには、ユーザーのフィードがあります。私はあなたがそれらを使用できると思います。また、PubSubHubbubに対応しているため、コメントやいいねをすぐに受け取ることができます。
また、2013 年 7 月 1 日をもって、Google リーダーは廃止されました。交換用のオプションには、スーパーフィーダーが含まれます。