Source Code: flickrsearch
<?php
require_once("phpFlickr/phpFlickr.php");
$username = "[USERNAME]";
$apiKey = "[APIKEY]";
$apiSecret ="[APISECRET]";
$authToken = '[AUTHTOKEN]'; //optional
// Create new phpFlickr object
$f = new phpFlickr($apiKey, $apiSecret);
$f->setToken($authToken);
$f->enableCache("db","mysql://USERNAME:PASSWORD@SERVER/DBNAME");
//or
$f->enableCache("fs","cache");
// Find the NSID of the username inputted via the form
$nsid = $f->people_findByUsername($username);
$keyword = '';
$flickrResults;
if($_GET['txtsearch'] ) {
$keyword =$_GET['txtsearch'];
$flickrResults = SearchFlickr($f,$keyword);
}
//Flickr Search using phpFlickr
function SearchFlickr($f,$keyword){
$tags = "\"".$keyword."\"";
$args = $args = array("tags"=>$keyword, "tag_mode"=>"all","per_page"=>"30");
$photos = $f->photos_search($args);
$html .="<div class='box'>";
$html .="<h2>Flickr: ".$keyword."</h2>";
if( count($photos['photo']) == 0) {
$html .= "<h3 class='error'>Sorry, No Photos match ".$heading."</h3>";
} else {
$i=0;
$html .= "<table width=100%><tr valign=top>";
foreach ($photos['photo'] as $photo) {
$html .= "<td>";
$html .= "<a href='".$f->buildPhotoURL($photo, "original")."' title='".$photo['title']."' >";
$html .= "<img border='0' alt='$photo[title]' "."src='".$f->buildPhotoURL($photo, "Square")."' id='photo_".$photo['id']."'></a>";
$html .= "<br><a href='http://flickr.com/photos/".$photo['owner']."'>Photo Page</a>";
$html .= "</td>";
$i++;
if($i==5) {
$html .="</tr><tr valign=top>";
$i=0;
}
}
$html .="</tr></table>";
}
$html .="</div>";
return $html;
}
?>





