Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Authenticating Google Reader

By: a guest on Jul 6th, 2010  |  syntax: PHP  |  size: 1.08 KB  |  views: 1,510  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. $ch = curl_init();
  2.        
  3.         curl_setopt($ch, CURLOPT_URL, "https://www.google.com/accounts/ClientLogin");
  4.         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  5.        
  6.         $data = array('accountType' => 'GOOGLE',
  7.         'Email' => 'emailgoeshere@gmail.com',
  8.         'Passwd' => 'passwordhere',
  9.         'source'=>'nameyourapp',
  10.         'service'=>'reader');
  11.        
  12.         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  13.         curl_setopt($ch, CURLOPT_POST, true);
  14.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  15.         curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  16.        
  17.         $loginResult = curl_exec($ch);
  18.        
  19.         // this is the meat:  grabbing the "Auth" value from the token we get back
  20.         $authRaw = strstr($loginResult, "Auth");
  21.         $authToken = substr($authRaw, 5);
  22.        
  23.         // this builds the action we'd like the API to perform
  24.         $ch = curl_init("http://www.google.com/reader/atom/user/-/state/com.google/reading-list");
  25.        
  26.         $header[] = 'Authorization: GoogleLogin auth='.$authToken;
  27.        
  28.         curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  29.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  30.         curl_setopt($ch, CURLOPT_HEADER, false);
  31.        
  32.         $xml = curl_exec($ch);
  33.         curl_close($ch);
clone this paste RAW Paste Data