Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

PHP Flickr! personal photo album

This code uses your Flickr! account and creates the URLs to the pictures for display on your own personal website! The full documentation is available at http://www.strydominc.za.net/index.php?p=projectdetail&d=phpflickrphoto

   1  
   2  <?php
   3  /**********************************************************************************************
   4  www.strydominc.za.net
   5  Created by Jurgen Strydom, 19-08-2006, jurgen.strydom@gmail.com
   6  Read the readme.txt
   7  Version 1.01, 19-08-2006
   8  **********************************************************************************************/
   9  ?>
  10  <link href="pagefloat.css" rel="stylesheet" type="text/css">
  11  <?php
  12  //Stuff you should update for your script
  13  $api_key = "6cacc91553b802874c6bbad658c9ce94"; // get yours at http://flickr.com/services/api/key.gne
  14  $my_id = "46772344@N00"; // use idgetr: http://idgettr.com/ to find yours if you already changed it to a name
  15  $rows = 10;
  16  //Let the code do the walking from here on
  17  $photos = ($rows * 2);
  18  if (empty($_REQUEST['n'])) {
  19  $pagenum = 1;
  20  } else {
  21  $pagenum = $_REQUEST['n'];
  22  }
  23  //http://static.flickr.com/{server-id}/{id}_{secret}_[mstb].jpg //how the url is created for the images
  24  $xml = simplexml_load_file("http://flickr.com/services/rest/?method=flickr.people.getPublicPhotos&user_id=$my_id&api_key=$api_key&per_page=$photos&page=$pagenum");
  25  $total = $xml->photos['total'];
  26  $pages = $total % $photos;
  27  $pages = ($total + $photos - $pages) / $photos;
  28  
  29  ?><table width="700" border="0" cellpadding="0" cellspacing="0">
  30  <tr><td height="10" colspan="2" valign="top" align="left">Please select a page: <?php
  31  for ($k = 1; $k<=$pages; $k++) { ?>
  32  <table width="25" border="0" cellpadding="0" cellspacing="0" align="center" class="pagefloat"> <?php
  33  ?>
  34    <tr>
  35      <td width="25" height="10" valign="top" align="center"><a href="photos.php?n=<?php echo $k?>">
  36  	<?php if ($k == $pagenum) {
  37  		 	echo "<u><b>", $k, "</b></u>";
  38  		 } else {
  39  		 	echo "<b>", $k, "</b>";
  40  		 } ?></a></td>
  41    </tr>
  42  </table>
  43  <?php } 
  44  ?>
  45  </td></tr>
  46  <tr>
  47      <td height="10" colspan="2" valign="top" align="left">&nbsp;</td>
  48  </tr>
  49  <?php
  50  
  51  if (($pagenum * $photos) > $total) {
  52  	$to = $total % $photos;
  53  } else { $to = $photos; }
  54  for ($k = 0; $k<$to; $k++) {
  55  if (($k % 2) == 0) {
  56  ?>
  57  <tr>
  58  <td width="350" height="100" valign="top" align="center">
  59  <?php } else {?>
  60  <td width="350" valign="top" align="center">
  61  <?php }
  62  echo "<b>" , $xml->photos->photo[$k]['title'], "</b>";
  63  ?>
  64  <br>
  65  <a href="http://www.flickr.com/photos/jurgenstrydom/<?php echo $xml->photos->photo[$k]['id'];?>"><img src="<?php 
  66  echo "http://static.flickr.com/";
  67  echo $xml->photos->photo[$k]['server'];
  68  echo "/";
  69  echo $xml->photos->photo[$k]['id'];
  70  echo "_";
  71  echo $xml->photos->photo[$k]['secret'];
  72  echo "_m.jpg"; 
  73  ?>"
  74  alt="<?php echo $xml->photos->photo[$k]['title'] ?>" border="0"></a>
  75  </td>
  76  <?php
  77  if (($k % 2) == 1) {
  78  ?> </tr>  <tr>
  79      <td height="10" colspan="2" valign="top" align="left">&nbsp;</td>
  80    </tr>  
  81    <?php
  82  }
  83  }
  84  ?>
  85  </table>
  86  <?php
  87  /**********************************************************************************************
  88  Changelog:
  89  
  90  Version 1.01
  91  Fixed a bug that caused code below this script to output incorrect display.
  92  
  93  Version 1
  94  First release.
  95  **********************************************************************************************/
  96  ?>
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS