Source Code: flickrlicious

<?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);
    

require_once(
'magpierss/rss_fetch.inc');

$keyword 'google';
$deliciousResults;
$flickrResults;
$yahooResults;

define("MAGPIE_CACHE_AGE",600);    // Cache time in seconds- 10 minutes
if(!file_exists("cache"))mkdir("cache",0775);

if(
$_GET['txtsearch'] ) {
    
$keyword =$_GET['txtsearch'];
    
$deliciousResults SearchDelicious($keyword);
    
$flickrResults SearchFlickr($f,$keyword);    
    
$yahooResults =SearchYahoo($keyword);
}

//del.icio.us Search using RSS
function SearchDelicious($keyword){
    
    
$keyword str_replace(" ""+"$keyword);
    
$rss fetch_rss("http://del.icio.us/rss/tag/".$keyword);
    
    
$rssItems $rss->items;    // News items
    
$maxRssItems 20;     // Maximum number of RSS news to show.
    
    
$html .= "<h2>del.ici.ous: ".$keyword."</h2>";    // Site title
    
    //echo min($maxRssItems,count($rssItems))."<br>";    // Number of news
    
    
$outputItems = array();    // Creating new array - this items holds the data we send back to the client
    
    
for($no=0;$no<count($rssItems);$no++){
        
#if(!isset($rssItems[$no]["pubdate"]))$rssItems[$no]["pubdate"]=$no;
        
if(!isset($rssItems[$no]["description"]))$rssItems[$no]["description"]=" ";
    
        
$key $rssItems[$no]["date_timestamp"].(5000 $no);
        
$outputItems[$key] = array(
            
"title"=>$rssItems[$no]["title"],
            
"date_timestamp"=>$rssItems[$no]["date_timestamp"],
            
"pubdate"=>$rssItems[$no]["pubdate"],
            
"description"=>$rssItems[$no]["description"],
            
"link"=>$rssItems[$no]["link"],
            
"category"=>$rssItems[$no]["category"]);    
    }
    
    
ksort($outputItems,SORT_NUMERIC);    // Sorting items from the key
    
$outputItems array_reverse($outputItems);    // Reverse array so that the newest item appear first
    
    
$countItems 0;
    
    foreach(
$outputItems as $key=>$value){    // Output items - looping throught the array $outputItems
        
$html .= "<p>";    
        
$html .= "<strong><a href='".preg_replace("/[\r\n]/"," ",$value["link"])."'>".preg_replace("/[\r\n]/"," ",$value["title"])."</a></strong><br>";    // Title
        
$html .=  preg_replace("/[\r\n]/"," ",$value["description"]);    // Description
        
$html .=  "</p>";    // Link
    
}
    return 
$html;    
}

//Flickr Search using phpFlickr
function SearchFlickr($f,$keyword){
    
$tags "\"".$keyword."\"";                
    
$args $args = array("tags"=>$keyword"tag_mode"=>"all","per_page"=>"20");        
    
$photos $f->photos_search($args);
    
$html .="<div class='small box'>";
    
$html .="<h2>Flickr: ".$keyword."</h2>";            
    
    if(    
count($photos['photo']) == 0) {            
        
$html .= "<h3 class='error'>Sorry, No Photos match ".$heading."</h3>";            
    } else {    
        
$html .= "<p id='photos' style='align:center;' >";
        foreach (
$photos['photo'] as $photo) {                                                  
            
$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> <br>";                  
        }
        
$html .="</p>";
    }         
    
$html .="</div>";
    
    return 
$html;
    
}

//Yahoo! Search Using REST
function SearchYahoo($keyword) {
    
    
$base "http://api.search.yahoo.com/WebSearchService/V1/webSearch";
    
$params = array("appid"=>"jrrxraqsrfgviny""query"=>$keyword,"results"=>"20");

    
$url  $base.'?'.http_build_query($params);

    
$c curl_init($url);
    
curl_setopt($c,CURLOPT_RETURNTRANSFER,true);
    
$response curl_exec($c);
    
curl_close($c);
            
    
$xml simplexml_load_string($response);
    
// Load up the root element attributes
    
$html .= "<h2>Yahoo! Search: ".$keyword."</h2>";
                
    
    foreach(
$xml->Result as $result) {  
        
$html .= "<p>\n";        
        
$html .= "<a href='".$result->ClickUrl."' title='".$result->DisplayUrl."'>".$result->Title."</a>";
        
$html .= "<br>";
        
$html .= $result->Summary;
        
$html .= "<br>";
        
//$html .= "<strong>Source: " .$result->DisplayUrl."</strong>";
    //    $html .= "<br>";
        
$html .= "</p>\n";
    
    }
    
    return 
$html;
}
?>