PHP
  Home arrow PHP arrow Page 4 - Implementing Yahoo Image Search Web Service with PHP 5
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
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? 
Google.com  
PHP

Implementing Yahoo Image Search Web Service with PHP 5
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 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:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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


    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!



     
     
    >>> More PHP Articles          >>> More By Alejandro Gervasio
     

       

    PHP ARTICLES

    - Implementing Factory Methods in PHP 5
    - Merging a File Split for FTP Upload using PHP
    - Getting Data from Yahoo Site Explorer Inboun...
    - Method Chaining: Adding More Selecting Metho...
    - How to Split a File During an FTP Upload Usi...
    - Expanding a Custom CodeIgniter Library with ...
    - Using the Yahoo Site Explorer Inbound Links ...
    - Building a CodeIgniter Custom Library with M...
    - Building an E-mini Trading System Using PHP ...
    - Completing the MySQL Class with Method Chain...
    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek