How to search yahoo images with PHP.
The following code is a basic example of how to use the Yahoo search API. An array of objects is returned containing the search results letting you create dynamic scripts to show images. This code could be used to make a simple plug-in for Wordpress to show images based on tags in your posts or you can use it in any PHP script.
<?php
$keyword =”Cool+Wallpaper”;
$request = ‘http://search.yahooapis.com/ImageSearchService/V1/imageSearch?appid=YahooDemo&query=’ . $keyword . ‘&results=12&output=php’;
$response = file_get_contents($request);
$phpobj = unserialize($response);
foreach($phpobj['ResultSet']['Result'] as $imgobj)
{
echo $imgobj['Thumbnail']['Url']; //The URL for the thumbnail
echo $imgobj['ClickUrl']; //The URL for the full image;
echo $imgobj['Width']; //The full picture width; ( Do I need to post the height example?)
}
?>
