【问题标题】:How to do ItemLookup with Zend Service Amazon?如何使用 Zend Service Amazon 进行 ItemLookup?
【发布时间】:2012-10-19 09:30:39
【问题描述】:

如果有人能指导我使用 Zend Amazon 服务模块(使用 Zend 2.0)按 ISBN 进行 ItemLookup 的正确方法,我将不胜感激。

这是我的尝试:

    $query  = new ZendService\Amazon\Query($appId, 'UK', $secretKey);
    $query->Category('Books')->IdType('ISBN')->ItemID('978-0321784070')->AssociateTag($tag);
    $result = $query->ItemLookup();

但我收到以下错误:

  • 缺少 ZendService\Amazon\Amazon::itemLookup() 的参数 1,在第 122 行的 D:\wamp\www\site\controllers\dev.php 中调用并定义
  • 未定义变量:asin

我无法定义 ASIN,因为我将拥有的唯一信息是 ISBN。

我已经在 zend 框架网站上查阅了 Zend Service Amazon 用户指南,但它已经过时并且没有演示如何进行 ISBN 查找。我还查看了 zend amazon 软件包附带的演示,但仅详细说明了如何进行项目搜索,而不是查找。

【问题讨论】:

    标签: php api codeigniter amazon zend-framework2


    【解决方案1】:

    这是一种让 ISBN 搜索工作的方法,我也花了一点时间才弄明白。问题在于,为了搜索 ISBN,您必须使用 ItemLookup 方法,而不是由 query() 方法设置的 ItemSearch 方法。

    可能有更好的方法可以使用 OO 界面使其工作,但我还没有尝试过。

    $query  = new ZendService\Amazon\Query($appId, 'US', $secretKey);
    $item   = $query->itemLookup('9780321784070',
                                 array('SearchIndex'   => 'Books',
                                       'AssociateTag'  => $tag,
                                       'IdType'        => 'ISBN',
                                       'ResponseGroup' => 'Small',));
    

    按 ISBN 搜索应返回单个 ZendService\Amazon\Item 对象,而不是结果数组。另请注意,如果您按 ISBN-13 进行搜索,则需要从号码中删除 -,否则将找不到匹配项。

    感谢 Manas Tungare 的 blog post,它向我暗示我们需要使用 IteamLookup 而不是 ItemSearch。

    【讨论】:

      猜你喜欢
      • 2012-10-21
      • 1970-01-01
      • 2017-02-05
      • 1970-01-01
      • 1970-01-01
      • 2012-10-09
      • 2010-12-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多