HomePHP Page 2 - Using Amazon Web Services With PHP And SOAP (part 2)
Rolling The Stones - PHP
In this concluding article, find out how to add search features to your AWS-backed online store, and link your product pages up to Amazon.com's shopping carts and wish lists.
The first - and the simplest - type of search available in AWS is the keyword search, exposed via the KeywordSearchRequest() call. Here's a simple example of how it works:
<?php
// include class
include("nusoap.php");
// create a instance of the
SOAP client object
$soapclient = new
soapclient("http://soap.amazon.com/schemas2/AmazonWebServices.wsdl",
true);
//
set up an array containing input parameters to be
// passed to the remote procedure
$params
= array(
'keyword' => 'rolling%20stones',
'page' =>
1,
'mode' => 'books',
'tag' => 'melonfire-20',
'type' => 'lite',
'devtag' => 'YOUR-TOKEN-HERE'
);
// create
a proxy so that WSDL methods can be accessed directly
$proxy = $soapclient->getProxy();
//
invoke the method
$result = $proxy->KeywordSearchRequest($params);
// print
the results
print_r($result);
?>
This is functionally similar to the scripts you've seen thus far; the primary
difference lies in the call to a new function - KeywordSearchRequest() - and in the different arguments passed to it. The "keyword" argument passed to the function contains the words to be used as search keys in the specified Amazon catalog(s); note that this search term must be URL-encoded before being passed to the function.