Created
August 5, 2011 15:31
-
-
Save hjr3/1127778 to your computer and use it in GitHub Desktop.
List subscriptions from Google Reader API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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