topical media & game development

talk show tell print

server-php-micro-flickr-index.php / php



  <?php
  // tags = "sea, sand, caribe, sunshine";
  tags = "creative technology";
  imageNumber = 5;
  
  function getFlickrRSS(){
     global tags, ids; 
      
     url = "http://api.flickr.com/services/feeds/photos_public.gne?format=rss2&tags=".tags;
     
     if (fp = fopen(url, 'r')) {
        content = '';
          
        while (line = fread(fp, 1024)) {
           content .= line;
        }
     }
  
     return content;  
  }
  
  function getImages(rssContent){
      global imageNumber;
      before = '<media:thumbnail url="';
      after  = '"';
      imageList = array();
      
      oldPos = 0;
      startPos=0;
      
      do {
          oldPos   = startPos;        
          startPos = strpos(rssContent,before,startPos) + strlen(before);
          endPos   = strpos(rssContent,after,startPos);
          imageList[] = substr(rssContent,startPos,endPos-startPos);
      } while ((startPos > oldPos) && (sizeof(imageList)<imageNumber));
         
      return imageList; 
  }
  
  content = getFlickrRSS();
  imageList = getImages(content);
  
  ?>
  
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
  <html>
  <head>
     <title>Micro Flickr </title>
     <link href="style/style.css" rel="stylesheet" type="text/css" />
  </head>
  <body>
      <div id="main">
        <div id="caption">flickr photos -- <?php echo tags ?></div>
        <div id="result">
           <?php 
              echo "<table><tr>";
              foreach (imageList as value) {
                     echo '<td><div class="imgW"> <div class="img100"><img src="'.value.'" /></div></div></td>';
              }
              echo "</tr></table>";         
           ?>
        </div>
        <div id="source">Micro Flickr 1.0</div>
      </div>
  </body> 
  


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