topical media & game development

talk show tell print

server-webapi-code-11-flickr-get-images.php / php



  <?php
  paramaters = array();
  endPoint = "http://www.flickr.com/services/rest/?";
  paramaters[] = array("method", "flickr.photos.search");
  paramaters[] = array("api_key", "KEY");
  paramaters[] = array("user_id", "USERID");
  
  /* Images by TAG:
          paramaters = array();
          paramaters[] = array("method", "flickr.photos.search");        
          paramaters[] = array("tags", "flower");
  */
  
  /* Restrict to License
          paramaters[] = array("license", "2");
  */
  
  foreach (paramaters AS paramater)
  {
          endPoint .= paramater[0] . "=" . paramater[1] . "&";
  }
  response = file_get_contents(endPoint);
  xml = simplexml_load_string(response);
  
  foreach(xml->photos->photo as photo)
  {
   echo "<img src=\"http://static.flickr.com/{photo['server']}/{photo['id']}_
    {photo['secret']}_m.jpg\" style=\"float: left; display: table-cell; width:   
    240px; height: 240px; text-align: center; vertical-align: middle;\">\n";
  }
  
  ?>
  


(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.