topical media & game development

talk show tell print

mashup-flickr-06-Step-4-lib-FlickrGallery.php / php



  <?php
  
  class FlickrGallery
  {
    var flickr;
    var nsid = '50317659@N00';
  
    function FlickrGallery()
    {
      global flickrApiKey;
      global flickrApiSecret;
  
      this->flickr = new phpFlickr(flickrApiKey, flickrApiSecret, false);
    }
  
    function findRecentPhotos(n = 20)
    {
      args = array(
      'user_id' => this->nsid,
      'sort' => 'date-posted-desc',
      'page' => 1, 
      'per_page' => n
       );
  
      p = this->flickr->photos_search(args);
      if (this->flickr->getErrorCode())
      {
        echo ("Error fetching photos: " . this->flickr->getErrorMsg());
      }
  
      return p['photo'];
    }
    
    function getPhotoInfo(id)
    {
      p = this->flickr->photos_getInfo(id);
      if (this->flickr->getErrorCode())
      {
        echo ("Error getting photo info: " . this->flickr->getErrorMsg());
      }
  
      return p;
    }
  }
  
  ?>
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.