Skip to content

Instantly share code, notes, and snippets.

@hjr3
Created August 5, 2011 15:31
Show Gist options
  • Save hjr3/1127778 to your computer and use it in GitHub Desktop.
Save hjr3/1127778 to your computer and use it in GitHub Desktop.
List subscriptions from Google Reader API
<?php
$email = 'example@gmail.com';
$password = 'secret';
$url = "https://www.google.com/accounts/ClientLogin?service=reader&Email={$email}&Passwd={$password}";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
curl_close($ch);
$parts = explode("\n", $output);
$auth = array();
foreach ($parts as $part) {
$tmp = explode('=', $part);
if ($tmp[0] && $tmp[1]) {
$auth[$tmp[0]] = $tmp[1];
}
}
$headers = array(
"Authorization: GoogleLogin auth={$auth['Auth']}",
);
$ch = curl_init('http://www.google.com/reader/api/0/subscription/list?output=json');
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$subs = curl_exec($ch);
curl_close($ch);
$subs = json_decode($subs);
print_r($subs);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment