com??™s t-shirts (see Figure 22-5).
Figure 22-5. Postal t-shirts from Amazon.com
CHAPTER 22 ?– USING AMAZON.COM WEB SERVICES 673
To exercise and build more XML links, just study the examples in the ???API Reference??? section
of the AWS documentation. The material will show you how to do a variety of Amazon.com
operations using REST.
Accessing Amazon.com E-Commerce Service Using SOAP
Using SOAP, you use a complex API to access the needed Amazon.com functionality. The following
code, which performs the same search operation for t-shirts that you did earlier with
REST, is using the AWSECommerceService, ItemSearch, and ItemSearchRequest objects from the
Amazon.com API to perform the operation.
?– Note To access the Amazon.com server using SOAP, we use the PHP SOAP extension. Make sure the
php_soap.dll reference in php.ini is not commented. You can find the documentation of the PHP SOAP
functionality at http://www.php.net/soap/.
To test accessing web services using SOAP, create a new file named test_soap.php in your
tshirtshop directory, and write the following code in it:
try
{
// Initialize SOAP client object
$client = new SoapClient(
'http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl');
/* DON'T FORGET to replace the string '[Your Access Key ID]' with your
subscription ID in the following line */
$request = array ('Service' => 'AWSECommerceService',
'AWSAccessKeyId' => '[Your Access Key ID]',
'Request' => array ('Operation' => 'ItemSearchRequest',
'Keywords' => 'postal+t-shirt',
'SearchIndex' => 'Apparel',
'ResponseGroup' =>
array ('Request',
'Medium',
'VariationSummary')));
$result = $client->ItemSearch($request);
CHAPTER 22 ?– USING AMAZON.
Pages:
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788