<?php  

function getAuthCode($authFile$user$password) {
    
    require(
$authFile);
    
    if (!isset(
$auth)) {
        
        
$ch curl_init();  
        
curl_setopt($chCURLOPT_URL"https://www.google.com/accounts/ClientLogin");          
        
$data = array('accountType' => 'GOOGLE',  
                   
'Email' => $user,  
                   
'Passwd' => $password,  
                   
'source'=>'PHI-cUrl-Example',  
                   
'service'=>'lh2');  
               
        
curl_setopt($chCURLOPT_SSL_VERIFYPEER0);  
        
curl_setopt($chCURLOPT_POSTtrue);  
        
curl_setopt($chCURLOPT_RETURNTRANSFERtrue);  
        
curl_setopt($chCURLOPT_POSTFIELDS$data);  
           
        
$data curl_exec($ch); 
        
$auth strstr($data'Auth=');

        
$write '<?php $auth = \''$auth .'\'; ?>';
        
        
$fp fopen($authFile'w');
        
fwrite($fp$write);

    }
    return 
$auth;
    
}

function 
getFeed($user$auth$querystring) {

    
$uri = (isset($_GET['albumid'])) ? "http://picasaweb.google.com/data/feed/base/user/".$user.'/albumid/'.$_GET['albumid'].'?'.$querystring "http://picasaweb.google.com/data/feed/base/user/".$user.'?'.$querystring;

    
$ch curl_init($uri);      
    
$header[] = 'Authorization: GoogleLogin '.$auth;  
      
    
curl_setopt($chCURLOPT_HTTPHEADER$header);  
    
curl_setopt($chCURLOPT_RETURNTRANSFERtrue);  
    
curl_setopt($chCURLOPT_HEADERfalse);  
      
    
$feed curl_exec($ch);  
    
curl_close($ch);

    echo 
$feed;

}

$authFile    'PicasaAuth.php';
$user        'username';
$password    'password';

$auth getAuthCode($authFile$user$password);
echo 
getFeed($user$auth$_SERVER['QUERY_STRING']);

?>