Пример #1
0
        function _PicasaTests()
        {
            $picasa = new Picasa();
			// Try login to system
			$login = $picasa->Authenticate("dicsydel", "GhNjkdFtg4", "lh2");
			$this->assertTrue($login, "Success login to google system");
			
			if ($login)
			{
    			$picasa->Username = "******";
    			
    			$res = $picasa->GetUserInfo();
    			$this->assertTrue($res["username"], "User info received");
    			if (!$res)
    			     print $picasa->GetLastWarning()."<br>";
    			
    		    $res = $picasa->GetAlbums();
    		    
    		    var_dump($res[0]);
    		    
    			$this->assertTrue(is_array($res), "Albums list received");
    			if (!$res)
    			     print $picasa->GetLastWarning()."<br>";
    			     
    			$res = $picasa->EditPhoto($res[0]['photos'][0]["id"], $res[0]['id'], $res[0]['photos'][0]["version"], "test123");
    			$this->assertTrue($res, "Photo metadata updated");
    			if (!$res)
    			     print $picasa->GetLastWarning()."<br>";
			}
        }
Пример #2
0
 public function actionPhoto($albumid)
 {
     $pic = new Picasa();
     $album = $pic->getAlbumById($this->username, $albumid, null, null, null, null, null, 1000);
     $images = $album->getImages();
     $albumTitle = $album->getTitle();
     //add meta tag fb
     Yii::app()->clientScript->registerMetaTag('1551369015136719', NULL, NULL, array('property' => 'fb:app_id'));
     Yii::app()->clientScript->registerMetaTag($albumTitle, NULL, NULL, array('property' => 'og:title'));
     Yii::app()->clientScript->registerMetaTag('article', NULL, NULL, array('property' => 'og:type'));
     foreach ($images as $image) {
         Yii::app()->clientScript->registerMetaTag($image->getContent(), NULL, NULL, array('property' => 'og:image'));
     }
     Yii::app()->clientScript->registerMetaTag(Yii::app()->getRequest()->getHostInfo() . Yii::app()->request->requestUri, NULL, NULL, array('property' => 'og:url'));
     Yii::app()->clientScript->registerMetaTag('Trang web chia sẻ ảnh và video của An An Cute', NULL, NULL, array('property' => 'og:description'));
     $this->pageTitle = 'An An Cute - ' . $albumTitle;
     $this->render('photo', array('images' => $images, 'albumid' => $albumid, 'albumTitle' => $albumTitle));
 }
Пример #3
0
function get_album($user, $album_id, $images_width = NULL)
{
    if ($images_width == NULL) {
        $images_width = '200,800';
    }
    // $images_width - размер возвращаемых изображений
    // для любителей кэша тут код а-ля, если есть кеш, берем данные из кеша:
    /*
            if (file_exists($_SERVER['DOCUMENT_ROOT'].'/cache/picasa_api_cache/'.$user.'/'.$album_name) )
              {
                  $album_data = unserialize(file_get_contents($_SERVER['DOCUMENT_ROOT'].'/cache/picasa_api_cache/'.$user.'/'.$album_name));
              }
              else      
              { // и нужно закрыть ручками это условие в конце функции
    */
    $pic = new Picasa();
    // Получаем данные для альбома, в последнем параметре указываем размеры необходимых изображений.
    // Можно также указать размеры: 72, 144, 200, 320, 400, 512, 576, 640, 720, 800, 912, 1024, 1152, 1280, 1440, 1600
    // googlesystem.blogspot.com/2006/12/embed-photos-from-picasa-web-albums.html
    $album = $pic->getAlbumById($user, $album_id, null, null, null, null, $images_width);
    // Получаем данные о изображениях в альбоме
    $images = $album->getImages();
    foreach ($images as $image) {
        $thumbnails = $image->getThumbnails();
        $album_data['images'][] = array('url' => (string) $thumbnails[1]->getUrl(), 'width' => (string) $thumbnails[1]->getWidth(), 'height' => (string) $thumbnails[1]->getHeight(), 'title' => (string) $image->getDescription(), 'tn_url' => (string) $thumbnails[0]->getUrl(), 'tn_width' => (string) $thumbnails[0]->getWidth(), 'tn_height' => (string) $thumbnails[0]->getHeight());
    }
    // иконка альбома
    $album_data['url'] = (string) $album->getIcon();
    $album_data['width'] = '160';
    $album_data['height'] = '160';
    $album_data['title'] = (string) $album->getTitle();
    // сохраняем данные в кеш (оставил это для тех кому нужно)
    //if(!is_dir($_SERVER['DOCUMENT_ROOT'].$cache_path.$user))
    //mkdir($_SERVER['DOCUMENT_ROOT'].$cache_path.$user,0777);
    //file_put_contents($_SERVER['DOCUMENT_ROOT'].$cache_path.$user.'/'.$album_name,serialize($album_data));
    return $album_data;
}
Пример #4
0
 /**
  * Constructs an array of {@link Picasa_Tag} objects based on the XML taken from either the $xml parameter or from the contents of $url.
  *
  * @param string $url             A URL pointing to a Picasa Atom feed that has zero or more "entry" nodes represeing
  *                                a Picasa tag.  Optional, the default is null.  If this parameter is null, the method will
  *                                try to get the XML content from the $xml parameter directly.
  * @param SimpleXMLElement $xml   XML from a Picasa Atom feed that has zero or more "entry" nodes represeing a Picasa tag.  
  *                                Optional, the default is null.  If the $url parameter is null and the $xml parameter is null,
  *                                a {@Picasa_Exception} is thrown.  
  * @throws Picasa_Exception       If the XML passed (through either parameter) could not be used to construct a {@link SimpleXMLElement}.
  * @return array                  An array of {@link Picasa_Tag} objects representing all tags in the requested feed.
  * @link http://php.net/simplexml
  */
 public static function getTagArray($url = null, SimpleXMLElement $xml = null, $contextArray = null)
 {
     if ($url != null) {
         $context = null;
         if ($contextArray != null) {
             $context = stream_context_create($contextArray);
         }
         $tagXml = @file_get_contents($url, false, $context);
         if ($tagXml == false) {
             throw Picasa::getExceptionFromInvalidQuery($url, $contextArray);
         }
     }
     try {
         // Load the XML file into a SimpleXMLElement
         $xml = new SimpleXMLElement($tagXml);
     } catch (Exception $e) {
         throw new Picasa_Exception($e->getMessage(), null, $url);
     }
     $tagArray = array();
     $i = 0;
     foreach ($xml->entry as $tag) {
         $tagArray[$i] = new Picasa_Tag($tag);
         $i++;
     }
     return $tagArray;
 }
Пример #5
0
<?php

include 'ClassPicasa.php';
$Url_1 = 'https://picasaweb.google.com/lh/photo/8ZZnCemRJfb4QjJsJtwQXNOydrU-8nQfVWbvDyT43k8?feat=directlink';
$Url_2 = 'https://picasaweb.google.com/103219276718020854069/Op?authkey=Gv1sRgCPih7_WYnbGKtAE#6038015163887814978';
$Url_3 = 'https://picasaweb.google.com/106600393574771987734/FT?authkey=Gv1sRgCKnRhK_ti4LgnQE#6170462589846807330';
// Bạn có thể ngẫu nhiên chọn một trong ba đường dẫn trên để gán vào biến $Picasa
$Picasa = new Picasa($Url_1);
echo $Picasa->get_480p_mp4() . '<br />';
echo $Picasa->get_720p_mp4() . '<br />';
Пример #6
0
 /**
  * Constructs an ImageCollection object from the Picasa XML feed.
  *
  * @param string $url    A query URL constructed according to the Picasa API documentation hosted by
  *                       Google at {@link http://code.google.com/apis/picasaweb/gdata.html#Add_Album_Manual_Web}.
  * @param SimpleXMLElement $albums  XML describing a Picasa image collection.  This can be left blank as long as a URL is 
  *                                  specified in the url parameter that returns valid XML for a Picasa image collection.  If both 
  *                                  are null, a {@link Picasa_Exception} is thrown.
  * @param array $contextArray       An array that can be passed to stream_context_create() to generate
  *                                  a PHP context.  See 
  *                                  {@link http://us2.php.net/manual/en/function.stream-context-create.php}
  * @throws {@link Picasa_Exception} If the XML suppled through either parameter does not contain valid XML.
  */
 public function __construct($url = null, SimpleXMLElement $collectionXml = null, $contextArray = null)
 {
     if ($url != null) {
         $context = null;
         if ($contextArray != null) {
             $context = stream_context_create($contextArray);
         }
         $xmldata = @file_get_contents($url, false, $context);
         if ($xmldata == false) {
             throw Picasa::getExceptionFromInvalidQuery($url, $contextArray);
         }
         //print $xmldata;
         try {
             // Load the XML file into a SimpleXMLElement
             $albums = new SimpleXMLElement($xmldata);
         } catch (Exception $e) {
             throw new Picasa_Exception($e->getMessage(), null, $url);
         }
         $namespaces = $albums->getNamespaces(true);
         if (array_key_exists("openSearch", $namespaces)) {
             $os_ns = $albums->children($namespaces["openSearch"]);
             $this->totalResults = $os_ns->totalResults;
             $this->startIndex = $os_ns->startIndex;
             $this->itemsPerPage = $os_ns->itemsPerPage;
         } else {
             $this->totalResults = null;
             $this->startIndex = null;
             $this->itemsPerPage = null;
         }
         $this->id = $albums->id;
         $this->title = $albums->title;
         $this->updated = $albums->updated;
         $this->icon = $albums->icon;
         $this->subtitle = $albums->subtitle;
         if ($albums->author != null && $albums->author != "") {
             $this->picasaAuthor = new Picasa_Author($albums->author);
             $this->author = $albums->author->name;
         } else {
             $this->picasaAuthor = null;
             $this->author = null;
         }
         $this->images = array();
         $i = 0;
         foreach ($albums->entry as $images) {
             $this->images[$i] = new Picasa_Image(null, $images);
             $i++;
         }
     }
 }
 /**
  * Constructs an Image object.
  *
  * @param string $url   URL of the query for the data that should be returned based on Picasa's API documentation.
  *                      See {@link http://code.google.com/apis/picasaweb/gdata.html} for instructions on how to formulate
  *                      the URL.  The URL parameter can be left blank, which will still produce a populated Image
  *                      object as long as the $albums parameter contains XML from the Picasa Atom feed for an image.
  * @param SimpleXMLElement $albums  XML describing a Picasa image.  This can be left blank as long as a URL is specified in the
  *                                  url parameter that returns valid XML for a Picasa image.  If both are null, a
  *                                  {@link Picasa_Exception} is thrown.
  * @param array $contextArray       An array that can be passed to stream_context_create() to generate
  *                                  a PHP context.  See
  *                                  {@link http://us2.php.net/manual/en/function.stream-context-create.php}
  * @param boolean $useCache  You can decide not to cache a specific request by passing false here.  You may
  *                           want to do this, for instance, if you're requesting a private feed.
  * @throws {@link Picasa_Exception} If the XML suppled through either parameter does not contain valid XML.
  */
 public function __construct($url = null, SimpleXMLElement $albums = null, $contextArray = null, $useCache = true)
 {
     if ($url != null) {
         Picasa_Logger::getLogger()->logIfEnabled('Request string: ' . $url);
         $context = null;
         $xmldata = false;
         if ($contextArray != null) {
             $context = stream_context_create($contextArray);
         }
         if ($useCache === true) {
             $xmldata = Picasa_Cache::getCache()->getIfCached($url);
         }
         if ($xmldata === false) {
             Picasa_Logger::getLogger()->logIfEnabled('Cached copy not available, requesting image freshly for URL: ' . $url);
             $xmldata = @file_get_contents($url, false, $context);
             if ($useCache === true && $xmldata !== false) {
                 Picasa_Logger::getLogger()->logIfEnabled('Saving account to cache.');
                 Picasa_Cache::getCache()->setInCache($url, $xmldata);
             }
         } else {
             Picasa_Logger::getLogger()->logIfEnabled('Image retreived from cache.');
         }
         if ($xmldata == false) {
             throw Picasa::getExceptionFromInvalidQuery($url, $contextArray);
         }
         try {
             // Load the XML file into a SimpleXMLElement
             $albums = new SimpleXMLElement($xmldata);
         } catch (Exception $e) {
             throw new Picasa_Exception($e->getMessage(), null, $url);
         }
     }
     $this->contextArray = $contextArray;
     if ($albums != null) {
         foreach ($albums->link as $plink) {
             if ($plink['rel'] == 'alternate') {
                 $this->weblink = $plink['href'];
             }
         }
         $namespaces = $albums->getNamespaces(true);
         if (array_key_exists("media", $namespaces)) {
             $media_ns = $albums->children($namespaces["media"]);
             $this->description = $media_ns->group->description;
             $this->keywords = $media_ns->group->keywords;
             $this->thumbUrlMap = array();
             $this->thumbHeightMap = array();
             $this->previous = null;
             $this->next = null;
             $i = 0;
             $this->thumbnails = array();
             $thumb = $media_ns->group->thumbnail[$i];
             while ($thumb != null) {
                 $thumbAtt = $thumb->attributes();
                 $width = "" . $thumbAtt['width'];
                 $height = $thumbAtt['height'];
                 $url = $thumbAtt['url'];
                 // These fields are deprecated but included for backwards compatibility
                 $this->thumbUrlMap[$width] = $url;
                 $this->thumbHeightMap[$width] = $height;
                 $this->thumbnails[$i] = new Picasa_Thumbnail($url, $thumbAtt['width'], $thumbAtt['height']);
                 $i++;
                 $thumb = $media_ns->group->thumbnail[$i];
             }
             /* This is to support the previous implementation.  It may seem inefficiant to loop
              * through twice, but typically there will be 1-3 iterations, so it is inconsequential. */
             $thumb = $media_ns->group->thumbnail[0];
             if ($thumb != null) {
                 $thumbAtt = $media_ns->group->thumbnail[0]->attributes();
                 $this->smallThumb = $thumbAtt['url'];
             } else {
                 $this->smallThumb = null;
             }
             $thumb = $media_ns->group->thumbnail[1];
             if ($thumb != null) {
                 $thumbAtt = $thumb->attributes();
                 $this->mediumThumb = $thumbAtt['url'];
             } else {
                 $this->mediumThumb = null;
             }
             $thumb = $media_ns->group->thumbnail[2];
             if ($thumb != null) {
                 $thumbAtt = $thumb->attributes();
                 $this->largeThumb = $thumbAtt['url'];
             } else {
                 $this->largeThumb = null;
             }
             $this->contentUrlMap = array();
             $this->contentHeightMap = array();
             $i = 0;
             $thumb = $media_ns->group->content[$i];
             while ($thumb != null) {
                 $thumbAtt = $thumb->attributes();
                 $width = "" . $thumbAtt['width'];
                 $height = $thumbAtt['height'];
                 $url = $thumbAtt['url'];
                 $this->contentUrlMap[$width] = $url;
                 $this->contentHeightMap[$width] = $height;
                 $i++;
                 $thumb = $media_ns->group->content[$i];
             }
             $this->content = $thumbAtt['url'];
             $this->imageType = $thumbAtt['type'];
             // Pull and parse the tags
             if ($media_ns->group->keywords != null || strcmp($media_ns->group->keywords, "") != 0) {
                 // Make an array for to hold all of a photo's tags
                 $this->tags = array();
                 /* Tags are stored as a comma-delimited list.
                  * Tokenize the list on comma and strip it to get just the tag.
                  */
                 $tok = strtok($media_ns->group->keywords, ",");
                 $i = 0;
                 while ($tok != false) {
                     // Set the tag in the array
                     $this->tags[$i] = trim($tok);
                     $tok = strtok(",");
                     $i++;
                 }
             } else {
                 $this->tags = null;
             }
         } else {
             $this->description = null;
             $this->keywords = null;
             $this->smallThumb = null;
             $this->mediumThumb = null;
             $this->largeThumb = null;
             $this->content = null;
         }
         if (array_key_exists("gphoto", $namespaces)) {
             $gphoto_ns = $albums->children($namespaces["gphoto"]);
             $this->idnum = $gphoto_ns->id;
             $this->width = $gphoto_ns->width;
             $this->height = $gphoto_ns->height;
             $this->albumid = $gphoto_ns->albumid;
             $this->albumTitle = $gphoto_ns->albumtitle;
             $this->albumDescription = $gphoto_ns->albumdesc;
             $this->version = $gphoto_ns->version;
             $this->timestamp = $gphoto_ns->timestamp;
             $this->commentingEnabled = $gphoto_ns->commentingEnabled;
             if (strcmp($gphoto_ns->commentCount, "") == 0 || $gphoto_ns->commentCount === null) {
                 $this->commentCount = null;
             } else {
                 $this->commentCount = intval($gphoto_ns->commentCount);
             }
         } else {
             $this->idnum = null;
             $this->width = null;
             $this->height = null;
             $this->albumid = null;
             $this->commentCount = null;
             $this->version = null;
             $this->timestamp = null;
         }
         if (array_key_exists("exif", $namespaces)) {
             $exif_ns = $albums->children($namespaces["exif"]);
             $this->flash = $exif_ns->tags->flash;
             $this->fstop = $exif_ns->tags->fstop;
             $this->cameraMake = $exif_ns->tags->make;
             $this->cameraModel = $exif_ns->tags->model;
             $this->exposure = $exif_ns->tags->exposure;
             $this->focalLength = $exif_ns->tags->focallength;
             $this->iso = $exif_ns->tags->iso;
         } else {
             $this->flash = null;
             $this->fstop = null;
             $this->cameraMake = null;
             $this->cameraModel = null;
             $this->exposure = null;
             $this->focalLength = null;
             $this->iso = null;
         }
         if (array_key_exists("georss", $namespaces)) {
             $georss_ns = $albums->children($namespaces["georss"]);
             $gml_ns = @$georss_ns->children($namespaces["gml"]);
             if ($gml_ns !== null || $gml_ns !== false) {
                 $this->gmlPosition = @$gml_ns->Point->pos;
             } else {
                 $this->gmlPosition = null;
             }
         } else {
             $this->gmlPosition = null;
         }
         // Set the basic attributes
         $this->id = $albums->id;
         $this->title = $albums->title;
         $this->updated = $albums->updated;
         if ($albums->author != null && strcmp($albums->author, "") != 0) {
             $this->author = new Picasa_Author($albums->author);
         } else {
             $this->author = new Picasa_Author();
         }
         // The user is not a field in the XML for an image like it is for an album.  Thus, we parse.
         if ($this->author->getUser() == null || strcmp($this->author->getUser(), "") == 0) {
             $startUser = strpos($this->id, '/user/') + 6;
             $endUser = strpos($this->id, '/', $startUser);
             $this->author->setUser(substr($this->id, $startUser, $endUser - $startUser));
         }
         // If there are comments, retrieve them and put them into the comments field of the object
         if ($this->commentCount === null) {
             $this->comments = null;
         } else {
             if ($this->commentCount === 0) {
                 $this->comments = array();
             } else {
                 $this->comments = array();
                 $i = 0;
                 // Grab each comment and make it into an object
                 foreach ($albums->entry as $comment) {
                     $this->comments[$i] = new Picasa_Comment($comment);
                     $i++;
                 }
             }
         }
     }
 }
Пример #8
0
 /**
  * Constructs an array of {@link Picasa_Author} objects based on the XML taken from either the $xml parameter or from the contents of $url.
  *
  * @param string $url                  A URL pointing to a Picasa Atom feed that has zero or more "entry" nodes represeing
  *                                     a Picasa author.  Optional, the default is null.  If this parameter is null, the method will
  *                                     try to get the XML content from the $xml parameter directly.
  * @param SimpleXMLElement $xml        XML from a Picasa Atom feed that has zero or more "entry" nodes represeing a Picasa author.  
  *                                     Optional, the default is null.  If the $url parameter is null and the $xml parameter is null,
  *                                     a {@Picasa_Exception} is thrown.  
  * @param array $contextArray          An array that can be passed to stream_context_create() to generate
  *                                     a PHP context.  See 
  *                                     {@link http://us2.php.net/manual/en/function.stream-context-create.php}
  * @param boolean $useCache            You can decide not to cache a specific request by passing false here.  You may
  *                                     want to do this, for instance, if you're requesting a private feed.
  * @throws {@link Picasa_Exception}    If the XML passed (through either parameter) could not be used to construct a {@link SimpleXMLElement}.
  * @return array                       An array of {@link Picasa_Author} objects representing all authors in the requested feed.
  * @see http://php.net/simplexml
  */
 public static function getAuthorArray($url = null, SimpleXMLElement $xml = null, $contextArray = null, $useCache = true)
 {
     if ($url != null) {
         $context = null;
         $authorXml = false;
         if ($contextArray != null) {
             $context = stream_context_create($contextArray);
         }
         if ($useCache === true) {
             $authorXml = Picasa_Cache::getCache()->getIfCached($url);
         }
         if ($authorXml === false) {
             Picasa_Logger::getLogger()->logIfEnabled("Not using cached entry for " . $url);
             $authorXml = @file_get_contents($url, null, $context);
             if ($useCache === true && $authorXml !== false) {
                 Picasa_Logger::getLogger()->logIfEnabled("Refreshing cache entry for key " . $url);
                 Picasa_Cache::getCache()->setInCache($url, $authorXml);
             }
         }
         if ($authorXml == false) {
             throw Picasa::getExceptionFromInvalidQuery($url);
         }
     }
     try {
         // Load the XML file into a SimpleXMLElement
         $xml = new SimpleXMLElement($authorXml);
     } catch (Exception $e) {
         throw new Picasa_Exception($e->getMessage(), null, $url);
     }
     $authorArray = array();
     $i = 0;
     foreach ($xml->entry as $author) {
         $authorArray[$i] = new Picasa_Author($author);
         $i++;
     }
     return $authorArray;
 }
<?php

// load picasa lightweight library
require_once 'wp-esprit-picasa-library-include.php';
$picasa = new Picasa();
Picasa::setPicasaUrl($_REQUEST['server']);
$status = True;
try {
    $account = $picasa->getAlbumsByUsername($_REQUEST['username'], 0);
} catch (Exception $e) {
    $status = False;
}
if ($_REQUEST['type'] == 'rpc') {
    $xml = "<picasa>";
    $xml .= "<status>";
    if ($status) {
        $xml .= "OK";
    } else {
        $xml .= "ERROR";
    }
    $xml .= "</status>\n";
    $xml .= "</picasa>";
    header('Content-type: text/xml');
    echo $xml;
}
Пример #10
0
 public function actionDetail($albumid, $imageid)
 {
     $pic = new Picasa();
     $image = $pic->getImageById($this->username, $albumid, $imageid, null, 1440);
     $this->render('detail', array('image' => $image));
 }
Пример #11
0
 /**
  * Dirty hack to reset the server url for picasa and all the related static variables.
  *
  * @static
  * @access public
  * @param string $url The url for picasa server
  * @return void
  */
 public static function setPicasaUrl($url)
 {
     if ($url != "") {
         if (strpos($url, 'http://') !== false) {
             $url = substr($url, 7);
         }
         self::$PICASA_URL = $url;
         self::$BASE_QUERY_URL = 'http://' . self::$PICASA_URL . '/data/feed/api';
         self::$BASE_ENTRY_QUERY_URL = 'http://' . self::$PICASA_URL . '/data/entry/api';
         self::$BASE_MEDIA_QUERY_URL = 'http://' . self::$PICASA_URL . '/data/media/api';
     }
 }
Пример #12
0
ini_set('include_path', './');
define('SITE_URL', 'http://localhost/nina/');
require_once 'Picasa.php';
$username = "******";
?>
<!DOCTYPE HTML>
<html lang="en-US">
    <head>
        <meta charset="UTF-8">
        <title>An An cute</title>
    </head>
    <body>
        <?php 
//Account Page
//For the account page, the only thing you'll need is the username. I recommend storing the username in a constant variable somewhere where all your code can access. This is so that if your username changes, or you want to give your code to someone else, you only have to change the username in one place. I store mine in a variable called "Cam_Util_PictureUtil::$USERNAME". However, for the sake of readability, I'll just refer to it in the following code as "$username". Here's the code for the account page, which just outputs each album's icon with a link to the album page. I use a URL structure similar to what my site uses, but modified to be closer to the typical setup. And obviously you can change the HTML to suit your needs:
$pic = new Picasa();
//        Picasa_Logger::getLogger()->setEnabled(true);
$account = $pic->getAlbumsByUsername($username);
$albums = $account->getAlbums();
foreach ($albums as $album) {
    print '<a href="http://www.your_web_site.com/album.php?albumid=' . $album->getIdnum() . '"><img src="' . $album->getIcon() . '" />';
    print '<div>' . $album->getTitle() . '</div>';
}
//        Album Page
//For the album page, you'll not only need the username, but you'll also need the album id. If you use the URL structure used in the previous example, you should be able to get the album id from the $_GET superglobal. I'll include how to do that in the code sample. So the album page just prints each image in the album with a link to the Image Page and the album title displayed below:
//        $albumid = $_GET["albumid"];
//        $pic = new Picasa();
//        $album = $pic->getAlbumById($username, $albumid);
//        $images = $album->getImages();
//        foreach ($images as $image)
//        {
Пример #13
0
 public function filter_post_picasa_images($out, $post)
 {
     try {
         // Check if there is any album requested
         $albumname = $post->info->picasa_album;
         if (!isset($albumname) || empty($albumname)) {
             return $out;
         }
         // TODO: Size to post options
         $size = "s200";
         //Check if the photos are already cached first because then we're already finished
         if (Cache::has(array(__CLASS__, "album_{$albumname}"))) {
             return Cache::get(array(__CLASS__, "album_{$albumname}"));
         }
         $picasa = new Picasa();
         $picasa->userid = $post->user_id;
         $this->cache_albumlist();
         $albumids = Cache::get(array(__CLASS__, "picasa_albumids"));
         $albumlinks = Cache::get(array(__CLASS__, "picasa_albumlinks"));
         // Get the actual photos
         $xml = $picasa->get_photos(array("album" => $albumids[$albumname]));
         foreach ($xml->entry as $photo) {
             // Warum drei URLs?
             // TODO: Irgendwas mit thumbnails machen
             $media = $photo->children('http://search.yahoo.com/mrss/');
             // $props['thumbnail_url'] = (string)$media->group->thumbnail->attributes()->url;
             $props['title'] = (string) $media->group->title;
             $props['description'] = (string) $media->group->description;
             $src = (string) $photo->content->attributes()->src;
             $props['url'] = substr($src, 0, strrpos($src, '/')) . "/{$size}" . substr($src, strrpos($src, '/'));
             $props['picasa_url'] = $src;
             $photos[] = $props;
         }
         // TODO: Add cache expire option to the admin interface
         Cache::set(array(__CLASS__, "album_{$albumname}"), $photos, 60 * 60 * 24);
     } catch (exception $e) {
         $photos = array(_t(vsprintf("No photos available or an error occured. Sometimes reloading the page helps. %s", $e), __CLASS__));
     }
     return $photos;
 }
<?php 
// load javascript and css files
echo "<script type='text/javascript' src='" . WP_PLUGIN_URL . "/" . str_replace(basename(__FILE__), '', plugin_basename(__FILE__)) . "js/wp-esprit-picasa-gallery.js" . "'></script>\n";
echo "<link rel='stylesheet' href='" . WP_PLUGIN_URL . "/" . str_replace(basename(__FILE__), '', plugin_basename(__FILE__)) . "css/style.css" . "' type='text/css' media='all' />\n";
?>

<?php 
// construct uri parameters which have to be passed with each request
$uriParams = WpEspritPicasa::$REQUEST_PARAMETER_POST_ID . "=" . $_REQUEST[WpEspritPicasa::$REQUEST_PARAMETER_POST_ID];
$uriParams .= "&" . WpEspritPicasa::$REQUEST_PARAMETER_TAB . "=" . $_REQUEST[WpEspritPicasa::$REQUEST_PARAMETER_TAB];
$uriParams .= "&" . WpEspritPicasa::$REQUEST_PARAMETER_TYPE . "=" . $_REQUEST[WpEspritPicasa::$REQUEST_PARAMETER_TYPE];
// how many photos we will display on each line
$albumsPerRow = 4;
// the size of the photo displayed in admin area
$albumThumbnailSize = "144";
$picasa = new Picasa();
Picasa::setPicasaUrl(get_option(WpEspritPicasa::$WP_OPTION_SERVER));
// get the album name from the request
$albumId = null;
if (isset($_REQUEST[WpEspritPicasa::$REQUEST_PARAMETER_ALBUM_ID])) {
    $albumId = $_REQUEST[WpEspritPicasa::$REQUEST_PARAMETER_ALBUM_ID];
}
$tab = $_REQUEST[WpEspritPicasa::$REQUEST_PARAMETER_TAB];
$html = "<div id=\"PicasaWrapper\">";
$i = 0;
if (is_null($albumId)) {
    $account = $picasa->getAlbumsByUsername(get_option(WpEspritPicasa::$WP_OPTION_USERNAME), null, null, null, $albumThumbnailSize . "c");
    foreach ($account->getAlbums() as $album) {
        $html .= $i % $albumsPerRow == 0 ? "<div class=\"row\">\n" : "";
        $html .= "  <div class=\"PicasaAlbums\">\n";
        $html .= "    <a href=\"" . $_SERVER["PHP_SELF"] . "?" . $uriParams . "&" . WpEspritPicasa::$REQUEST_PARAMETER_ALBUM_ID . "=" . $album->getIdnum() . "\">\n";
Пример #15
0
 /**
  * Constructs an array of {@link Picasa_Comment} objects based on the XML taken from either the $xml parameter or from the contents of $url.
  *
  * @param string $url                  A URL pointing to a Picasa Atom feed that has zero or more "entry" nodes represeing
  *                                     a Picasa comment.  Optional, the default is null.  If this parameter is null, the method will
  *                                     try to get the XML content from the $xml parameter directly.
  * @param SimpleXMLElement $xml        XML from a Picasa Atom feed that has zero or more "entry" nodes represeing a Picasa comment.  
  *                                     Optional, the default is null.  If the $url parameter is null and the $xml parameter is null,
  *                                     a {@Picasa_Exception} is thrown.  
  * @param array $contextArray          An array that can be passed to stream_context_create() to generate
  *                                     a PHP context.  See 
  *                                     {@link http://us2.php.net/manual/en/function.stream-context-create.php}
  * @throws {@link Picasa_Exception}    If the XML passed (through either parameter) could not be used to construct a {@link SimpleXMLElement}.
  * @return array                       An array of {@link Picasa_Comment} objects representing all comments in the requested feed.
  * @see http://php.net/simplexml
  */
 public static function getCommentArray($url = null, SimpleXMLElement $xml = null, $contextArray = null)
 {
     if ($url != null) {
         $context = null;
         if ($contextArray != null) {
             $context = stream_context_create($contextArray);
         }
         // Get the XML document from Picasa's server based on the query in the URL
         $commentXml = @file_get_contents($url, null, $context);
         if ($commentXml == false) {
             throw Picasa::getExceptionFromInvalidQuery($url);
         }
     }
     try {
         // Load the XML file into a SimpleXMLElement
         $xml = new SimpleXMLElement($commentXml);
     } catch (Exception $e) {
         throw new Picasa_Exception($e->getMessage(), null, $url);
     }
     $commentArray = array();
     $i = 0;
     // Create a blank Album object for each album in the account
     foreach ($xml->entry as $comment) {
         $commentArray[$i] = new Picasa_Comment($comment);
         $i++;
     }
     return $commentArray;
 }
Пример #16
0
 /**
  * Constructs an Account object.  
  * This method assigns Album objects to the Account,
  * but the Album objects that are constructed will not initially contain Image objects.  This is 
  * because the XML that is returned from Picasa does not contain individual Image nodes
  * for each Album, presumeably because it could potentially take a lot of time to fetch
  * every image in an Account when all you likely need are the Albums.  Starting with version
  * 3.0 of this API, the images are fetched from Picasa when {@link Picasa_Album::getImages()}
  * is called and {@link Picasa_Album::$images} is null. 
  *  
  * @param string $url    The URL for the specific query that should be returned, as defined 
  *			 in Picasa's API documentation (http://code.google.com/apis/picasaweb/gdata.html).
  *			 Optional, the default is null.  If this parameter is null, the xml must
  *			 come from the $xml parameter.
  * @param SimpleXMLElement $xml  XML from a Picasa Atom feed represeting a Picasa Account. Optional,
  *                                      the default is null.  If this parameter and the $url parameters are
  *                                      both null, a {@link Picasa_Exception} is thrown.  You cannot create
  *                                      an empty Picasa_Account instance.
  * @param array $contextArray  An array that can be passed to the PHP built in function {@link stream_context_create()}.
  *                             It contains useful information when retrieving a feed, including headers that
  *                             might include needed authorization information.
  * @param boolean $useCache  You can decide not to cache a specific request by passing false here.  You may
  *                           want to do this, for instance, if you're requesting a private feed.
  * @throws Picasa_Exception  If valid XML cannot be retrieved from the URL specified in $url or $xml. 
  */
 public function __construct($url = null, SimpleXMLElement $xml = null, $contextArray = null, $useCache = true)
 {
     if ($url != null) {
         Picasa_Logger::getLogger()->logIfEnabled('Request string: ' . $url);
         $context = null;
         $xmldata = false;
         if ($contextArray != null) {
             $context = stream_context_create($contextArray);
         }
         if ($useCache === true) {
             $xmldata = Picasa_Cache::getCache()->getIfCached($url);
         }
         if ($xmldata === false) {
             Picasa_Logger::getLogger()->logIfEnabled('Cached copy not available, requesting account freshly for URL: ' . $url);
             $xmldata = @file_get_contents($url, false, $context);
             if ($useCache === true && $xmldata !== false) {
                 Picasa_Logger::getLogger()->logIfEnabled('Saving account to cache.');
                 Picasa_Cache::getCache()->setInCache($url, $xmldata);
             }
         } else {
             Picasa_Logger::getLogger()->logIfEnabled('Account retreived from cache.');
         }
         if ($xmldata === false) {
             throw Picasa::getExceptionFromInvalidQuery($url, $contextArray);
         }
         try {
             // Load the XML file into a SimpleXMLElement
             $xml = new SimpleXMLElement($xmldata);
         } catch (Exception $e) {
             throw new Picasa_Exception($e->getMessage(), null, $url);
         }
     }
     // The basic data can easily be loaded from the XML
     $this->author = $xml->author->name;
     $this->id = $xml->id;
     $this->title = $xml->title;
     $this->subtitle = $xml->subtitle;
     $this->icon = $xml->icon;
     $this->picasaAuthor = new Picasa_Author($xml->author);
     foreach ($xml->link as $plink) {
         if ($plink['rel'] == 'alternate') {
             $this->weblink = $plink['href'];
         }
     }
     // Create an array to hold the albums in the account
     $this->albums = array();
     $i = 0;
     // Create a blank Album object for each album in the account
     foreach ($xml->entry as $albums) {
         $this->albums[$i] = new Picasa_Album(null, $albums);
         $i++;
     }
 }
 /**
  * Executes a request.
  * This is a pretty generic PHP function for the most part.  The only parts that are specific to Picasa
  * is the errors that are thrown.  PHP doesn't have a built in function that does this very well (although there are packages
  * for it that can be installed), so this manually sets the HTTP headers and parses the whole response.
  *
  * @access protected
  * @static
  * @param string $host       The destination address to send the request to.  It should not include a protocol.
  * @param string $path       The path on the host to send the request to.  It should start with a "/"
  * @param string $data       Any data that should be sent along with the request.  If there is no data, leave it as null.
  * @param string $request    The type of request to perform.  Most common are GET, POST, PUT, and DELETE.  The type of
  *                           request to use for each Picasa function is defined in Picasa's official documentation.
  * @param array $specialHeaders  An array of strings of headers that should be sent with the request.  The headers that are
  *                               always sent are Host, Content-Type, and Content-Length.  The most common type of special
  *                               header is an authorization header from Google.  Note that even if there is only one special header,
  *                               it still must be in an array.  Also note that each line in the array should end in "\r\n" and
  *                               should be set in the array with double quotes, not single quotes, because "\r\n" is interpreted
  *                               differently by PHP if single quotes are used.  Optional, the default is null.
  * @param string $type       The type of content that will is being sent through the request.  Optional, the default is
  *                           "application/x-www-form-urlencoded".
  * @param string $protocol   The protocol to use when sending the request.  Secure requests should use "ssl://".  Note that
  *                           the protocol must end in "://" unless it's an empty string.  For HTTP, this parameter can be left
  *                           as an empty string.  Optional, the default is an empty string.
  * @param int $port          The port number to send the request to.  Different protocols have different port numbers.  HTTP protocol
  *                           uses port 80 and SSL uses port 443.  Optional, the default is 80.
  * @return string            The entire response, including headers, that was recieved from the host.
  * @throws {@link Picasa_Exception}  If a response of "200" or "201" is not recieved.  In this case, the entire contents of the response,
  *                                   including headers, is set to the $response field of the exception and the error supplied by
  *                                   Picasa is set as the exceptions message.  The idea is that the calling method can search the
  *                                   response for a specific return code (for instance, a File Not Found or Forbidden error) and throw
  *                                   a more specific exception.  The caller can also search the response for values that are specific
  *                                   to its request, such as a Captcha URL.
  */
 protected static function do_request($host, $path, $data, $request, $specialHeaders = null, $type = "application/x-www-form-urlencoded", $protocol = "", $port = "80")
 {
     $contentlen = strlen($data);
     $req = "{$request} {$path} HTTP/1.1\r\nHost: {$host}\r\nContent-Type: {$type}\r\nContent-Length: {$contentlen}\r\n";
     if (is_array($specialHeaders)) {
         foreach ($specialHeaders as $header) {
             $req .= $header;
         }
     }
     $req .= "Connection: close\r\n\r\n";
     if ($data != null) {
         $req .= $data;
     }
     Picasa_Logger::getLogger()->logIfEnabled("Request to do: " . $request);
     $fp = fsockopen($protocol . $host, $port, $errno, $errstr);
     if (!$fp) {
         throw new Picasa_Exception($errstr);
     }
     fputs($fp, $req);
     $buf = "";
     if (!feof($fp)) {
         $buf = @fgets($fp);
     }
     Picasa_Logger::getLogger()->logIfEnabled("Buffer returned: " . $buf);
     // If either a 200 or 201 response is not found, there was a problem so throw an exception
     if (preg_match("/200 /i", $buf) || preg_match("/201 /i", $buf)) {
         while (!feof($fp)) {
             $buf .= @fgets($fp);
         }
         fclose($fp);
         return $buf;
     } else {
         /* In the response returned from Picasa, it is really hard to pull out the error message.
          * Its location is two lines below the "Connection: Close" line.  So that message is pulled
          * out, if possible, and set as the Exception's message.  Also, the entire buffer is sent.
          * This way, the caller can throw it's own message by looking for its own response code.
          */
         $expMessage = "An unknown error has occured while sending a {$request} request.";
         $break = false;
         $tmpBuf = "";
         while (!feof($fp)) {
             $tmpBuf = @fgets($fp);
             $buf .= $tmpBuf;
             if (strcmp($tmpBuf, "Connection: Close\r\n") == 0) {
                 for ($i = 0; !feof($fp); $i++) {
                     if ($i == 2) {
                         $expMessage = @fgets($fp);
                         $buf .= $expMessage;
                         $break = true;
                     } else {
                         $buf .= @fgets($fp);
                     }
                 }
             }
         }
         if (!$break) {
             $msg = Picasa::getResponseValue($buf, "Error");
             if ($msg != null) {
                 $expMessage = $msg;
             }
         }
         throw new Picasa_Exception($expMessage, $buf, $host . $path);
     }
 }
Пример #18
0
 private function _CheckServer($Url)
 {
     if ($this->__Server == 1) {
         $Goo = new Picasa($Url);
         $Link = $Goo->_get();
         unset($Goo);
     } elseif ($this->__Server == 2) {
         $Link = YoutbeDownloader::getInstance()->getLink($Url);
     } elseif ($this->__Server == 3) {
         $Object = new ZingTV($Url);
         $Link = $Object->_Get();
         unset($Object);
     } else {
         return '#Error';
     }
     return $Link;
 }
Пример #19
0
 /**
  * Constructs an array of {@link Picasa_Comment} objects based on the XML taken from either the $xml parameter or from the contents of $url.
  *
  * @param string $url                  A URL pointing to a Picasa Atom feed that has zero or more "entry" nodes represeing
  *                                     a Picasa comment.  Optional, the default is null.  If this parameter is null, the method will
  *                                     try to get the XML content from the $xml parameter directly.
  * @param SimpleXMLElement $xml        XML from a Picasa Atom feed that has zero or more "entry" nodes represeing a Picasa comment.  
  *                                     Optional, the default is null.  If the $url parameter is null and the $xml parameter is null,
  *                                     a {@Picasa_Exception} is thrown.  
  * @param array $contextArray          An array that can be passed to stream_context_create() to generate
  *                                     a PHP context.  See 
  *                                     {@link http://us2.php.net/manual/en/function.stream-context-create.php}
  * @param boolean $useCache            You can decide not to cache a specific request by passing false here.  You may
  *                                     want to do this, for instance, if you're requesting a private feed.
  * @throws {@link Picasa_Exception}    If the XML passed (through either parameter) could not be used to construct a {@link SimpleXMLElement}.
  * @return array                       An array of {@link Picasa_Comment} objects representing all comments in the requested feed.
  * @see http://php.net/simplexml
  */
 public static function getCommentArray($url = null, SimpleXMLElement $xml = null, $contextArray = null, $useCache = true)
 {
     if ($url != null) {
         $context = null;
         $commentXml = false;
         if ($contextArray != null) {
             $context = stream_context_create($contextArray);
         }
         if ($useCache === true) {
             $commentXml = Picasa_Cache::getCache()->getIfCached($url);
         }
         if ($commentXml === false) {
             Picasa_Logger::getLogger()->logIfEnabled("Comments not coming from the cache.");
             // Get the XML document from Picasa's server based on the query in the URL
             $commentXml = @file_get_contents($url, null, $context);
             if ($useCache === true && $commentXml !== false) {
                 Picasa_Logger::getLogger()->logIfEnabled("Refreshing cache entry for comments.");
                 Picasa_Cache::getCache()->setInCache($url, $commentXml);
             }
         } else {
             Picasa_Logger::getLogger()->logIfEnabled("Comments coming from the cache.");
         }
         if ($commentXml === false) {
             throw Picasa::getExceptionFromInvalidQuery($url);
         }
     }
     try {
         // Load the XML file into a SimpleXMLElement
         $xml = new SimpleXMLElement($commentXml);
     } catch (Exception $e) {
         throw new Picasa_Exception($e->getMessage(), null, $url);
     }
     $commentArray = array();
     $i = 0;
     // Create a blank Album object for each album in the account
     foreach ($xml->entry as $comment) {
         $commentArray[$i] = new Picasa_Comment($comment);
         $i++;
     }
     return $commentArray;
 }
Пример #20
0
 /**
  * Constructs an Album object.  
  * When called, this method will fill out each private member	
  * of the Album object based on XML returned from Picasa's Atom feed.  It will also create
  * a Picasa_Image object for each image in the Album by passing XML for each image into 
  * the Picasa_Image constructor.	
  *
  * @param string $url   The URL of the Picasa query to retrieve the XML from.  See
  *                      http://code.google.com/apis/picasaweb/gdata.html for information on
  *                      how to format the URL.  If null, it is assumed that $albums param
  *                      has been supplied.
  * @param SimpleXMLElement $albums  XML for constructing the object.  If null, it is assumed that the 
  *                                  URL to the Atom feed has been supplied.  If both are null, a
  *                                  {@link Picasa_Exception} is thrown.
  * @param array $contextArray       An array that can be passed to stream_context_create() to generate
  *                                  a PHP context.  See 
  *                                  {@link http://us2.php.net/manual/en/function.stream-context-create.php}
  * @param boolean $useCache  You can decide not to cache a specific request by passing false here.  You may
  *                           want to do this, for instance, if you're requesting a private feed.
  * @throws {@link Picasa_Exception} If the XML suppled through either parameter does not contain valid XML.
  */
 public function __construct($url = null, SimpleXMLElement $albums = null, $contextArray = null, $useCache = true)
 {
     if ($url != null) {
         $xmldata = false;
         $context = null;
         Picasa_Logger::getLogger()->logIfEnabled('Request string: ' . $url);
         if ($contextArray !== null) {
             $context = stream_context_create($contextArray);
         }
         if ($useCache === true) {
             $xmldata = Picasa_Cache::getCache()->getIfCached($url);
         }
         if ($xmldata === false) {
             Picasa_Logger::getLogger()->logIfEnabled("Not using cached entry for " . $url);
             $xmldata = @file_get_contents($url, false, $context);
             if ($useCache === true && $xmldata !== false) {
                 Picasa_Logger::getLogger()->logIfEnabled("Refreshing cache entry for key " . $url);
                 Picasa_Cache::getCache()->setInCache($url, $xmldata);
             }
         }
         if ($xmldata === false) {
             throw Picasa::getExceptionFromInvalidQuery($url, $contextArray);
         }
         try {
             // Load the XML file into a SimpleXMLElement
             $albums = new SimpleXMLElement($xmldata);
         } catch (Exception $e) {
             throw new Picasa_Exception($e->getMessage(), null, $url);
         }
         // I'm not sure why there's a difference, but the icon is given in different ways
         // depending on if the document is just for an Album or if it's part of a larger document
         $this->icon = $albums->icon;
     }
     // Whether or not the contextArray is null, it should be set.
     $this->contextArray = $contextArray;
     if ($albums != null) {
         $namespaces = $albums->getNamespaces(true);
         $this->picasaAuthor = new Picasa_Author($albums->author);
         $this->editLink = null;
         $link = $albums->link[0];
         $i = 0;
         while ($link != null) {
             $attributes = $albums->link[$i]->attributes();
             if (strcmp($attributes["rel"], "edit") == 0) {
                 $this->editLink = $attributes["href"];
                 break;
             } else {
                 if (strcmp($attributes["rel"], "alternate") == 0) {
                     $this->weblink = $attributes["href"];
                 }
             }
             $i++;
             $link = $albums->link[$i];
         }
         if (array_key_exists("gphoto", $namespaces)) {
             $gphoto_ns = $albums->children($namespaces["gphoto"]);
             $this->location = $gphoto_ns->location;
             $this->idnum = $gphoto_ns->id;
             $this->numphotos = $gphoto_ns->numphotos;
             $this->photosRemaining = $gphoto_ns->numphotosremaining;
             $this->bytesUsed = $gphoto_ns->bytesUsed;
             $this->commentingEnabled = $gphoto_ns->commentingEnabled;
             $this->numComments = $gphoto_ns->commentCount;
             $this->timestamp = $gphoto_ns->timestamp;
             // The picasaAuthor field must be set before this line is executed
             if ($this->picasaAuthor->getUser() == null || strcmp($this->picasaAuthor->getUser(), "") == 0) {
                 $this->picasaAuthor->setUser($gphoto_ns->user);
             }
         }
         if (array_key_exists("media", $namespaces)) {
             $media_ns = $albums->children($namespaces["media"]);
             // As stated above, this is to account for the different placement of icon
             if ($url === null) {
                 $thumbAtt = $media_ns->group->thumbnail->attributes();
                 $this->icon = $thumbAtt["url"];
             }
         }
         if (array_key_exists("georss", $namespaces)) {
             $georss_ns = $albums->children($namespaces["georss"]);
             $gml_ns = $georss_ns->children($namespaces["gml"]);
             $this->gmlPosition = @$gml_ns->Point->pos;
         }
         $this->id = $albums->id;
         $this->title = $albums->title;
         $this->updated = $albums->updated;
         $this->published = $albums->published;
         $this->summary = $albums->summary;
         $this->rights = $albums->rights;
         $this->author = $albums->author->name;
         $this->subtitle = $albums->subtitle;
         $this->comments = null;
         $this->images = array();
         $i = 0;
         //Create a new Image object for each Image element
         foreach ($albums->entry as $images) {
             $this->images[$i] = new Picasa_Image(null, $images);
             $i++;
         }
     }
 }
Пример #21
0
 /**
  * Constructs an Account object.  
  * This method assigns Album objects to the Account,
  * but the Album objects that are constructed will not initially contain Image objects.  This is 
  * because the XML that is returned from Picasa does not contain individual Image nodes
  * for each Album, presumeably because it could potentially take a lot of time to fetch
  * every image in an Account when all you likely need are the Albums.  Starting with version
  * 3.0 of this API, the images are fetched from Picasa when {@link Picasa_Album::getImages()}
  * is called and {@link Picasa_Album::$images} is null. 
  *  
  * @param string $url    The URL for the specific query that should be returned, as defined 
  *			 in Picasa's API documentation (http://code.google.com/apis/picasaweb/gdata.html).
  *			 Optional, the default is null.  If this parameter is null, the xml must
  *			 come from the $accountXml parameter.
  * @param SimpleXMLElement $accountXml  XML from a Picasa Atom feed represeting a Picasa Account. Optional,
  *                                      the default is null.  If this parameter and the $url parameters are
  *                                      both null, a {@link Picasa_Exception} is thrown.  You cannot create
  *                                      an empty Picasa_Account instance.
  * @param array $contextArray  An array that can be passed to the PHP built in function {@link stream_context_create()}.
  *                             It contains useful information when retrieving a feed, including headers that
  *                             might include needed authorization information.
  * @throws Picasa_Exception  If valid XML cannot be retrieved from the URL specified in $url or $accountXml. 
  */
 public function __construct($url = null, SimpleXMLElement $accountXml = null, $contextArray = null)
 {
     if ($url != null) {
         $context = null;
         if ($contextArray != null) {
             $context = stream_context_create($contextArray);
         }
         // Get the XML document from Picasa's server based on the query in the URL
         $accountXml = @file_get_contents($url, false, $context);
         if ($accountXml == false) {
             throw Picasa::getExceptionFromInvalidQuery($url, $contextArray);
         }
     }
     try {
         // Load the XML file into a SimpleXMLElement
         $xml = new SimpleXMLElement($accountXml);
     } catch (Exception $e) {
         throw new Picasa_Exception($e->getMessage(), null, $url);
     }
     // The basic data can easily be loaded from the XML
     $this->author = $xml->author->name;
     $this->id = $xml->id;
     $this->title = $xml->title;
     $this->subtitle = $xml->subtitle;
     $this->icon = $xml->icon;
     $this->picasaAuthor = new Picasa_Author($xml->author);
     // Create an array to hold the albums in the account
     $this->albums = array();
     $i = 0;
     // Create a blank Album object for each album in the account
     foreach ($xml->entry as $albums) {
         $this->albums[$i] = new Picasa_Album(null, $albums);
         $i++;
     }
 }