1

我想使用 PHP 和 Zend 框架检索书籍图像和 ISBN 号。你能帮我吗?

$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);
}

在此代码中,输出为:

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)
)

但是您会看到,图像字段都是空的,并且没有 ISBN 字段。你对此有什么想法吗?

4

1 回答 1

1

使用 'ResponseGroup' 参数来指定结果中您想要的数据:

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

ItemAttributes 会给你一堆额外的数据,包括 ISBN。

于 2012-06-10T21:26:05.703 回答