PHP
  Home arrow PHP arrow Page 4 - Implementing Yahoo Image Search Web Se...
CIO Insight
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Implementing Yahoo Image Search Web Service with PHP 5
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 3
    2008-01-29

    Table of Contents:
  • Implementing Yahoo Image Search Web Service with PHP 5
  • Using the Yahoo! Web Search Service with PHP 5
  • Implementing the Image Search Service in PHP 5
  • Implementing the Yahoo! Image Search Service with PHP 5

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
     
    ADVERTISEMENT

    The Web Buyer's Guide is your best source for white papers on a wide range of IT products and services. This Week's Featured White Papers: Taming the Threat Landscape by Symantec

    Implementing Yahoo Image Search Web Service with PHP 5 - Implementing the Yahoo! Image Search Service with PHP 5
    (Page 4 of 4 )

    If you’ve been paying attention to the approach that I followed in earlier sections of this article to implement with PHP 5 some of the most popular web services provided by Yahoo!, then it’s quite probable that you'll find the following example very easy to grasp. It demonstrates in a friendly fashion how to use the pertinent image search service by using the same script that you learned previously.

    Invoking the aforementioned Yahoo! web service through PHP requires coding only a simple PHP code snippet, like the one that follows:

    // example using Yahoo! Image Search Service - results are displayed in a basic (X)HTML format utilizing a procedural approach


    try{

    $request='http://search.yahooapis.com/ImageSearchService/V1/imageSearch?
    appid=Your-AP-ID&query=Madonna&results=2&output=php';

    // trigger the http request

    if(!$results=file_get_contents($request)){

    throw new Exception('Error requesting Yahoo! Web service');

    }

    $results=unserialize($results);

    foreach($results[ResultSet][Result] as $result){

    echo '<h2>'.$result[Title].'</h2><p>'.$result[Summary].'</p><p><img
    src="'.$result[Thumbnail][Url].'" width="'.$result[Thumbnail][Width].'"
    height="'.$result[Thumbnail][Height].'" /></p><a href="'.$result[Url].'">'.$result
    [Url].'</a>';

    }

    }

    catch(Exception $e){

    echo $e->getMessage();

    exit();

    }

    As you can see, the above script looks very similar to the one that I used to query the Yahoo! Video Search Service, so I won’t give you boring explanations of how it works. The only thing you need to notice is how the corresponding image results are extracted from the returned serialized array, something that, at this point, should also be familiar to you. Besides, with the purpose of completing the previous explanation on using the popular Yahoo! Image Search Service with PHP 5, below I listed the pair of results produced by the prior script. Here they are:

    // search results displayed by the previous script are as follows


    Madonna_vogue.jpg


    Madonna_3.jpg 30-Apr-2005 14:34 23k Madonna_9.jpg 30-Apr-2005 14:34 23k
    Madonna_vogue.jpg 30-Apr-2005 14:35 22k Madonna_13.jpg 30-Apr-2005 14:34
    22k


    http://www.multinet.no/~jonarne/Hjemmesia/Favorittartister/madonna/
    Madonna_vogue.jpg

    madonna_90563a.jpg


    ANGRER: Madonna spiller gjerne pa sex for a provosere, men angrer pa boken Sex.- Jeg lurer stadig pa hva som motiverte meg til a lage den, sier hun om sin vagale bok, Sex , som vakte


    http://pub.tv2.no/multimedia/TV2/archive/00090/madonna_90563a.jpg

    At this stage I provided enough material for you to get started using the most relevant web services offered by Yahoo! within your own PHP 5 applications. So I recommend that you practice with these code samples to expand your skills in utilizing these handy services with PHP 5.

    Final thoughts

    In this third part of the series I showed you how to work with serialized PHP arrays and how to quickly parse the results returned by the Yahoo! Video and Image Search services -- certainly a process that can be tackled with minor hassles.

    Nonetheless, this instructive journey hasn’t ended yet, since in the next article I’m going to show you how to invoke all of those helpful web services by defining some simple, efficient custom PHP functions. This could be useful if you’re using a procedural approach to develop your PHP applications.

    Now that you’ve been alerted to the topics that will be covered in the upcoming tutorial, you don’t have any excuses to miss it!


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · Over this third chapter of the series, you’ll learn how to consume other helpful web...
     

       

    PHP ARTICLES

    - Comparing Files and Databases with PHP Bench...
    - Setting Up a Web-Based Image Gallery
    - Using Timers to Benchmark PHP Applications
    - Benchmarking Applications with PHP
    - Setting Up a Web-Based File Manager: PHPfile...
    - Developing a Modular Class For a PHP File Up...
    - Setting Up a Web-Based File Manager: bfExplo...
    - Defining a Custom Function for File Uploader...
    - Parsing Child Nodes with the DOM XML extensi...
    - Creating an Error Handling Module for a PHP ...
    - Accessing Attributes and Cloning Nodes with ...
    - Retrieving Information on Selected Files wit...
    - Handling HTML Strings and Files with the DOM...
    - Building File Uploaders with PHP 5
    - Working with Multiple Document Nodes with th...




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway