我想使用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字段。你对此有什么想法吗?
答案 0 :(得分:1)
使用'ResponseGroup'参数来确定结果中所需的数据:
$results = $amazon->itemSearch(array(
'SearchIndex' => 'Books',
'Keywords' => "php",
'AssociateTag' => "php",
'ResponseGroup' => 'ItemAttributes'
));
ItemAttributes将为您提供一系列额外数据,包括ISBN。