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

PHP Flickr! personal photo album (See related posts)

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

<?php
/**********************************************************************************************
www.strydominc.za.net
Created by Jurgen Strydom, 19-08-2006, jurgen.strydom@gmail.com
Read the readme.txt
Version 1.01, 19-08-2006
**********************************************************************************************/
?>
<link href="pagefloat.css" rel="stylesheet" type="text/css">
<?php
//Stuff you should update for your script
$api_key = "6cacc91553b802874c6bbad658c9ce94"; // get yours at http://flickr.com/services/api/key.gne
$my_id = "46772344@N00"; // use idgetr: http://idgettr.com/ to find yours if you already changed it to a name
$rows = 10;
//Let the code do the walking from here on
$photos = ($rows * 2);
if (empty($_REQUEST['n'])) {
$pagenum = 1;
} else {
$pagenum = $_REQUEST['n'];
}
//http://static.flickr.com/{server-id}/{id}_{secret}_[mstb].jpg //how the url is created for the images
$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");
$total = $xml->photos['total'];
$pages = $total % $photos;
$pages = ($total + $photos - $pages) / $photos;

?><table width="700" border="0" cellpadding="0" cellspacing="0">
<tr><td height="10" colspan="2" valign="top" align="left">Please select a page: <?php
for ($k = 1; $k<=$pages; $k++) { ?>
<table width="25" border="0" cellpadding="0" cellspacing="0" align="center" class="pagefloat"> <?php
?>
  <tr>
    <td width="25" height="10" valign="top" align="center"><a href="photos.php?n=<?php echo $k?>">
	<?php if ($k == $pagenum) {
		 	echo "<u><b>", $k, "</b></u>";
		 } else {
		 	echo "<b>", $k, "</b>";
		 } ?></a></td>
  </tr>
</table>
<?php } 
?>
</td></tr>
<tr>
    <td height="10" colspan="2" valign="top" align="left">&nbsp;</td>
</tr>
<?php

if (($pagenum * $photos) > $total) {
	$to = $total % $photos;
} else { $to = $photos; }
for ($k = 0; $k<$to; $k++) {
if (($k % 2) == 0) {
?>
<tr>
<td width="350" height="100" valign="top" align="center">
<?php } else {?>
<td width="350" valign="top" align="center">
<?php }
echo "<b>" , $xml->photos->photo[$k]['title'], "</b>";
?>
<br>
<a href="http://www.flickr.com/photos/jurgenstrydom/<?php echo $xml->photos->photo[$k]['id'];?>"><img src="<?php 
echo "http://static.flickr.com/";
echo $xml->photos->photo[$k]['server'];
echo "/";
echo $xml->photos->photo[$k]['id'];
echo "_";
echo $xml->photos->photo[$k]['secret'];
echo "_m.jpg"; 
?>"
alt="<?php echo $xml->photos->photo[$k]['title'] ?>" border="0"></a>
</td>
<?php
if (($k % 2) == 1) {
?> </tr>  <tr>
    <td height="10" colspan="2" valign="top" align="left">&nbsp;</td>
  </tr>  
  <?php
}
}
?>
</table>
<?php
/**********************************************************************************************
Changelog:

Version 1.01
Fixed a bug that caused code below this script to output incorrect display.

Version 1
First release.
**********************************************************************************************/
?>

Comments on this post

Alkine posts on Nov 30, 2006 at 11:09
The latest version of this code is available at http://www.flatspike.com/projects/php/php-flickr-personal-photo-album/

You need to create an account or log in to post comments to this site.


Click here to browse all 5147 code snippets

Related Posts