GoogleリーダーにはAPIがありますか?その場合、特定のユーザーのユーザー名とパスワードを知っている未読の投稿数を取得するにはどうすればよいですか?GoogleリーダーAPI未読数
26
A
答えて
45
このURLはフィードごとに未読の投稿数をカウントします。その後、フィードを繰り返してカウントを合計することができます。ここで
http://www.google.com/reader/api/0/unread-count?all=true
Pythonでミニマルな例です... XML/JSONを解析し、カウントを合計すると、読者の課題として残されている:
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
そして、上のいくつかの追加のリンクトピック:
11
0
[1]、 "トークン" フィールドは "T" であるべきである
6
import urllib
import urllib2
username = '[email protected]'
password = '******'
# Authenticate to obtain Auth
auth_url = 'https://www.google.com/accounts/ClientLogin'
#auth_req_data = urllib.urlencode({'Email': username,
# 'Passwd': password})
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)
# SID = auth_resp_dict["SID"]
AUTH = auth_resp_dict["Auth"]
# Create a cookie in the header using the Auth
header = {}
#header['Cookie'] = 'Name=SID;SID=%s;Domain=.google.com;Path=/;Expires=160000000000' % SID
header['Authorization'] = 'GoogleLogin auth=%s' % AUTH
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
に更新され
2010年6月頃にGoogle ReaderがSID authを削除しました(私は思う)、ClientLoginからの新しいAuthを使用するのは新しいやり方です。(ヘッダーは短くなります) 。 Auth
をリクエストするためにservice
をデータに追加する必要があります。service=reader
を送信しない場合は、Auth
が返されませんでした。
this threadでは、認証方法の変更について詳しく読むことができます。
関連する問題
- 1. GoogleリーダーAPIフィードのアイテム数
- 2. GoogleリーダーAPI PHPライブラリ
- 3. GoogleリーダーAPIリーダーのユーザーIDをGoogleアカウントにリンクする
- 4. 未読アイテムを保持するRSSリーダー
- 5. GoogleリーダーのAPIマークを読み取り済み
- 6. Googleリーダー編集API認証の問題
- 7. GoogleリーダーAPI:ストリーム/アイテム/ IDの継続
- 8. APIを使用してGoogleリーダーでフィードを購読する方法
- 9. キャッチコピーエラー:Google未定義| Google Maps API
- 10. Googleリーダーでのアイテムの動的読み込み
- 11. GoogleリーダーOAuthマークを読み取り済み
- 12. GoogleリーダーやAPIヘルプのコード例はありますか?
- 13. Googleリーダーにブログ投稿の「共有」を照会するAPI
- 14. GoogleリーダーAPIを使用して詳細がわかる場合
- 15. NFCリーダーでデータを読む
- 16. 未定義参照JSON ::値とJSON ::リーダー
- 17. Google Maps APIを使用した未定義のJavascript変数
- 18. Google Maps API - Latlng関数は未定義を返します
- 19. GoogleカレンダーAPI v3 - 未定義のコンストラクターエラー
- 20. GoogleカレンダーAPI - 未定義のイベント
- 21. Google Maps JS API - 未定義 'point.pageX'
- 22. Google MapsのAPI JS - MarkerClusterer - 未定義
- 23. GoogleリーダーAPIで読み取ったアイテムにマークを付けるにはどうすればよいですか?
- 24. FB api-pullページのメールボックスからの未読メッセージ数
- 25. Gmail API経由で未読メッセージの数を取得
- 26. Uncaught TypeError:未定義の 'calendar'プロパティを読み取れません - GoogleカレンダーAPI
- 27. Google Analytics APIを使用したエリアグラフ - 未知のタイプエラーが未定義のライブラリを読み取れない
- 28. Google APIの許可関数がスローします 'TypeError:未定義の' $ k 'プロパティを読み取れません。
- 29. Googleリーダーからフィードをインポートする
- 30. Googleリーダーのフィード一意のID
@GateKiller:これに「コードリクエスト」タグを投げる動機を理解しています...唯一の答えが(破損した)APIドキュメントへのリンクである質問に公開賞金をもらっています私は私のキーワードをグーグルで見つけた人に300リペアを支払うことになるだろうと私を苛立たせる。 – Shog9
しかし、タグは目的を果たさない。むしろ、実際の質問にサンプルコードを理解してほしいというメモを追加する必要があります。 – Shog9