<?php
$tags = "sea, sand, caribe, sunshine";
$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</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>