GoogleReaerのRSS登録者数をPHPで取得
以下のURLで登録数を調べることができます。3行目に表示されるのが登録者数。3行目がUnKnownだった場合は登録者数が0人。
http://www.google.com/reader/directory/search?hl=en&q=サイトURL
phpで上記のurlを取得するには、php上でのログインのようなことが必要です。
以下で取得できます。グーグルアカウントのログインID(password)とパスワードを入力してください。
$data = array(
'accountType' => 'GOOGLE',
'Email' => '[email protected]',
'Passwd' => 'password',
'service' => 'reader'
);
$options = array(
'http' => array(
'method' => 'POST',
'content' => http_build_query($data)
)
);
$response = @file_get_contents('https://www.google.com/accounts/ClientLogin', false, stream_context_create($options));
$auth = explode("\n", $response);
$header = array(
'Authorization: GoogleLogin auth='. substr($auth[2], 5,1024)
);
$options = array(
'http' => array(
'method' => 'GET',
'header' => $header
)
);
//取得
$response = @file_get_contents('http://www.google.com/reader/directory/search?hl=en&q=typing.netgamers.jp', false, stream_context_create($options));
//登録者数の部分だけ取得
preg_match('/span\sclass..number..(.*)<\/span>.subscribers/is',$response,$subscribers);
//登録者数を出力
echo $subscribers[1];