LIGHT
LIGHT

Reputation: 5712

How do I retrieve book image and ISBN number using Zend framework and PHP

I want to retrieve book image and ISBN number using PHP and Zend framework. Can you help me in this?

$amazon = new Zend_Service_Amazon(AMAZON_API_KEY, 'US', AMAZON_SECRET_KEY);

$results = $amazon->itemSearch(array(
    'SearchIndex' => 'Books',
    'Keywords' => "php",
    'AssociateTag' => "php"
));

foreach ($results as $result) {
  print_r($result);
}

Here in this code gives the output as :

Zend_Service_Amazon_Item Object
(
    [ASIN] => 0596157134
    [DetailPageURL] => http://www.amazon.com/Learning-PHP-MySQL-JavaScript-Step-By-Step/dp/0596157134%3FSubscriptionId%3DAKIAJH3FSKNQTTD2DQZQ%26tag%3Dphp%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D0596157134
    [SalesRank] => 
    [TotalReviews] => 
    [AverageRating] => 
    [SmallImage] => 
    [MediumImage] => 
    [LargeImage] => 
    [Subjects] => 
    [Offers] => 
    [CustomerReviews] => Array
        (
        )

    [SimilarProducts] => Array
        (
        )

    [Accessories] => Array
        (
        )

    [Tracks] => Array
        (
        )

    [ListmaniaLists] => Array
        (
        )

    [_dom:protected] => DOMElement Object
        (
        )

    [Author] => Robin Nixon
    [Manufacturer] => O'Reilly Media
    [ProductGroup] => Book
    [Title] => Learning PHP, MySQL, and JavaScript: A Step-By-Step Guide to Creating Dynamic Websites (Animal Guide)
)

but you see, the image fields are all empty and there is not field for ISBN. Do you have any idea for this?

Upvotes: 1

Views: 1966

Answers (1)

Tim Fountain
Tim Fountain

Reputation: 33148

Use the 'ResponseGroup' param to specific what data you want in the result:

$results = $amazon->itemSearch(array(
    'SearchIndex' => 'Books',
    'Keywords' => "php",
    'AssociateTag' => "php",
    'ResponseGroup' => 'ItemAttributes'
));

ItemAttributes will give you a bunch of extra data including the ISBN.

Upvotes: 1

Related Questions