PHP
  Home arrow PHP arrow Page 4 - Using Amazon Web Services With PHP And...
Dev Shed Forums 
Administration  
AJAX  
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 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Moblin 
JMSL Numerical Library 
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: 4 stars4 stars4 stars4 stars4 stars / 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:
      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


    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

    - Building a Database-Driven Application with ...
    - User Authentication for a Project Management...
    - Introduction to the CodeIgniter PHP Framework
    - Adding Users for a Project Management Applic...
    - Migrating Class Code for a MIME Email to PHP...
    - Login and Logout Authentication for a Projec...
    - Composing Messages in HTML for MIME Email wi...
    - Project Management: Authentication
    - A Better Way to Determine MIME Types for MIM...
    - Project Management Overview
    - Handling Attachments in MIME Email with PHP
    - Completing the Project Management Application
    - Sending MIME Email with PHP
    - Handling Files for a Project Management Appl...
    - Viewing and Editing Tasks for a Project Mana...





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