PHP
  Home arrow PHP arrow Page 4 - Using Amazon Web Services With PHP And SOAP (part 2)
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? 
PHP

Using Amazon Web Services With PHP And SOAP (part 2)
By: icarus, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 21
    2002-11-13


    Table of Contents:
  • Using Amazon Web Services With PHP And SOAP (part 2)
  • Rolling The Stones
  • Searching For Words
  • Drilling Deeper
  • Riding The Popularity Metrics
  • Bagging It
  • Linking Out

  • 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


    Using Amazon Web Services With PHP And SOAP (part 2) - Drilling Deeper
    ( Page 4 of 7 )

    AWS also allows you to look for items in specific categories, supporting searches by author, actor, artist and manufacturer. Here's a list of the relevant methods:

    AuthorSearchRequest() - search by author;

    ArtistSearchRequest() - search by artist or musician;

    ActorSearchRequest() - search by actor or actress;

    DirectorSearchRequest() - search by director;

    ManufacturerSearchRequest() - search by product manufacturer;

    With methods like these, it's easy to build a more powerful search engine for your store. Take a look:

    <html> <head> <basefont face="Verdana"> </head> <body bgcolor="white"> <p>&nbsp;<p> <table width="100%" cellspacing="0" cellpadding="5"> <tr> <td bgcolor="Navy"><font color="white" size="-1"><b>Search</b></font></td> <td bgcolor="Navy" align="right"><font color="white" size="-1"><b><? echo date("d M Y", mktime());?></b></font></td> </tr> </table> <p> <? if (!$_POST['q']) { ?> Select a category and enter a search term: <form method="post" action="<? echo $_SERVER['PHP_SELF']; ?>"> <select name="type"> <option value="author">Author</option> <option value="artist">Artist</option> <option value="actor">Actor</option> <option value="director">Director</option> <option value="manufacturer">Manufacturer</option> </select> <input type="text" name="q"> </form> <? } else { $type = $_POST['type']; // include class include("nusoap.php"); // create a instance of the SOAP client object $soapclient = new soapclient("http://soap.amazon.com/schemas2/AmazonWebServices.wsdl", true); // create a proxy so that WSDL methods can be accessed directly $proxy = $soapclient->getProxy(); // set up an array containing input parameters to be // passed to the remote procedure // use a switch loop to define the search parameters for each type switch ($type) { case "author": $mode = "books"; $func = "AuthorSearchRequest"; break; case "artist": $mode = "music"; $func = "ArtistSearchRequest"; break; case "actor": $mode = "vhs"; $func = "ActorSearchRequest"; break; case "director": $mode = "vhs"; $func = "DirectorSearchRequest"; break; case "manufacturer": $mode = "electronics"; $func = "ManufacturerSearchRequest"; break; } $params = array( $type => htmlentities($_POST['q']), 'page' => 1, 'mode' => $mode, 'tag' => 'melonfire-20', 'type' => 'lite', 'devtag' => 'YOUR-TOKEN-HERE' ); // invoke the method $result = $proxy->$func($params); $total = $result['TotalResults']; $items = $result['Details']; // format and display the results ?> Your search for <b><? echo $_POST['q']; ?></b> returned <? echo $total; ?> matches. <p> <table width="100%" border="0" cellspacing="5" cellpadding="0"> <? // parse the $items[] array and extract the necessary information foreach ($items as $i) { ?> <tr> <td align="center" valign="top" rowspan="3"><a href="<? echo $i['Url']; ?>"><img border="0" src=<? echo $i['ImageUrlSmall']; ?>></a></td> <td><font size="-1"><b><? echo $i['ProductName']; ?></b> / <? if (is_array($i['Authors'])) { echo implode(", ", $i['Authors']); } else if (is_array($i['Artists'])) { echo implode(", ", $i['Artists']); } else if ($i['Manufacturer']) { echo $i['Manufacturer']; }?> </font></td> </tr> <tr> <td align="left" valign="top"><font size="-1">List Price: <? echo $i['ListPrice']; ?> / Amazon.com Price: <? echo $i['OurPrice']; ?></font></td> </tr> <tr> <td align="left" valign="top"><font size="-1"><a href="<? echo $i['Url']; ?>">Read more about this title on Amazon.com</a></font></td> </tr> <tr> <td colspan=2>&nbsp;</td> </tr> <? } ?> </table> <? } ?> </body> </html>
    In this case, I've simply added a new item to my search form - a drop-down list containing a list of the categories to search in. Each of these categories corresponds to one of the AWS methods listed above, and my PHP form processor uses a "switch" statement to call the appropriate method and pass it the search keywords. The result is then processed in the usual way, and formatted for display to the user.

    Here are a couple of screenshots demonstrating how this works:





     
     
    >>> More PHP Articles          >>> More By icarus, (c) Melonfire
     

       

    PHP ARTICLES

    - Using Directory Iterators to Build Loader Ap...
    - Using the spl_autoload() Functions to Build ...
    - Working Out of the Object Context to Build L...
    - Using the _autoload() Magic Function to Buil...
    - The Destruct Magic Function in PHP 5
    - The Autoload Magic Function in PHP 5
    - Developing a Recursive Loading Class for Loa...
    - The Sleep and Wakeup Magic Functions in PHP 5
    - Using the Clone Magic Function in PHP 5
    - Including Files Recursively with Loader Appl...
    - The Call Magic Function in PHP 5
    - Designing a Captcha System with PHP and MySQL
    - Using Static Methods to Build Loader Apps in...
    - The Isset and Unset Magic Functions in PHP 5
    - Advanced PHP Form Input Validation to Check ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
    Stay green...Green IT