如何使用 Zend Service Amazon 进行 ItemLookup? [英] How to do ItemLookup with Zend Service Amazon?

查看:19
本文介绍了如何使用 Zend Service Amazon 进行 ItemLookup?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I would appreciate if anyone could guide me on the correct way on doing an ItemLookup by ISBN using the Zend Amazon Service module (with Zend 2.0).

这是我的尝试:

    $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.

There is no way I can define the ASIN because the only information I will have is the ISBN.

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

I have already consulted the Zend Service Amazon user guide in the zend framework website but it is outdated and doesn't demonstrate how to do an ISBN lookup. I have also looked at the demo that came with the zend amazon package but that only details how to do item searches, not lookups.

推荐答案

这是一种使 ISBN 搜索工作的方法,我也花了一些时间才弄明白.问题是,为了搜索 ISBN,您必须使用 ItemLookup 方法,而不是由 query()ItemSearch 方法> 方法.

Here is a way to get the ISBN search working, it took me a little while to get it figured out as well. The problem was that in order to search for ISBN you must use the ItemLookup method rather than the ItemSearch method which was getting set by the query() method.

使用 OO 接口可能有更好的方法来让它工作,但我还没有尝试过.

There may be a better way to get this to work using the OO interface but I haven't tried that yet.

$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 进行搜索,则需要从号码中去除 -,否则将找不到匹配项.

Searching by ISBN should return a single ZendService\Amazon\Item object rather than an array of results. Also be aware, if you search by ISBN-13, you need to strip the - from the number or it won't find a match.

归功于此 博客文章 由 Manas Tungare 向我暗示我们需要使用 IteamLookup 而不是 ItemSearch.

Credit to this blog post by Manas Tungare which hinted to me that we need to use IteamLookup instead of ItemSearch.

这篇关于如何使用 Zend Service Amazon 进行 ItemLookup?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆