PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Performing Amazon Item Searches

Searching for items based on any of various available criteria are made simple using the itemSearch() method, as in the following example:

Example 714. Performing Amazon Item Searches

<?php
$amazon 
= new Zend_Service_Amazon('AMAZON_API_KEY''US''AMAZON_SECRET_KEY');
$results $amazon->itemSearch(array('SearchIndex' => 'Books',
                                     
'Keywords' => 'php'));
foreach (
$results as $result) {
    echo 
$result->Title '<br />';
}

Example 715. Using the ResponseGroup Option

The ResponseGroup option is used to control the specific information that will be returned in the response.

<?php
$amazon 
= new Zend_Service_Amazon('AMAZON_API_KEY''US''AMAZON_SECRET_KEY');
$results $amazon->itemSearch(array(
    
'SearchIndex'   => 'Books',
    
'Keywords'      => 'php',
    
'ResponseGroup' => 'Small,ItemAttributes,Images,SalesRank,Reviews,' .
                       
'EditorialReview,Similarities,ListmaniaLists'
    
));
foreach (
$results as $result) {
    echo 
$result->Title '<br />';
}

The itemSearch() method accepts a single array parameter for handling search options. For full details, including a list of available options, please see the relevant Amazon documentation

Tip

The Zend_Service_Amazon_Query class is an easy to use wrapper around this method.

Zend Framework