Created
April 3, 2009 09:56
-
-
Save deplorableword/89690 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Get photos from a flickr pool and make a cache, | |
html output is setup ready for lightbox plugin coolness | |
tom@substrakt.co.uk | |
*/ | |
$cacheFile = 'flickrcache.html'; | |
$cacheTime = 4 * 60; | |
// Serve the cached file if it is older than $cacheTime | |
if (file_exists($cacheFile) && time() - $cacheTime < filemtime($cacheFile)) { | |
include($cacheFile); | |
exit; | |
} | |
// Start the output buffer | |
ob_start(); | |
// put your code here | |
$url = 'http://api.flickr.com/services/rest/?method=flickr.groups.pools.getPhotos&api_key=55dac60b830123643c001b2fd317d04b&group_id=1071453%40N23&per_page=30&auth_token=72157616204991191-b5b8c5278b94b68f&api_sig=56647e8e38a3fff7231a3871bed2f848'; | |
$result = simplexml_load_file($url); | |
foreach ($result->photos->photo as $photo) { | |
$thumb = 'http://farm'.$photo['farm'].'.static.flickr.com/'.$photo['server'].'/'.$photo['id'].'_'.$photo['secret'].'_m.jpg'; | |
$med = 'http://farm'.$photo['farm'].'.static.flickr.com/'.$photo['server'].'/'.$photo['id'].'_'.$photo['secret'].'.jpg'; | |
echo '<a href="'.$med.'" rel="lightbox" title="Added by '.$photo['ownername'].'">'; | |
echo '<img src="'.$thumb.'" alt="'.$photo['title'].'" />'; | |
echo '</a>'; | |
} | |
// Cache the contents to a file | |
$cached = fopen($cacheFile, 'w'); | |
fwrite($cached, ob_get_contents()); | |
fclose($cached); | |
ob_end_flush(); // Send the output to the browser | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment