昔からGoogle Readerの非公式APIを使ってみたかったので、 こちらを参考にPerlでアクセスしてみてる。
既読のアイテムのタイトルを表示するだけのスクリプトなら以下のコードになりました。 上記のサイトだとCookieにSIDを設定しろって書いてあるけれど、 「Authorization」ヘッダーに適切な値を入れてアクセスしたらデータが取れた。
use strict;
use warnings;
use LWP::UserAgent;
use XML::Feed;
my $email = 'my@emailaddress';
my $password = 'mypassword';
my $ua = LWP::UserAgent->new;
my $res = $ua->post(
'https://www.google.com/accounts/ClientLogin',
{
service => 'reader',
Email => $email,
Passwd => $password,
source => 'reader_from_perl',
continue => 'http://www.google.com/',
}
);
die $res->status_line if $res->is_error;
my $content = $res->content;
my ($auth) = $content =~ /Auth=(.+?)\n/;
$ua->default_header( 'Authorization' => "GoogleLogin auth=$auth" );
$res = $ua->get('http://www.google.com/reader/atom/user/-/state/com.google/read');
die $res->status_line if $res->is_error;
$content = $res->content;
my $feed = XML::Feed->parse( \$content ) or die XML::Feed->errstr;
for my $entry ( $feed->entries ) {
print $entry->title . "\n";
}
まだPerlで作るかiOSで作るかわからんが、こういうのを試すにPerlは便利ですな。