3

我正在使用 Zend Service Amazon 2.0 使用关键字搜索书籍。现在,代码正在搜索所有书籍,而不考虑子类别。我怎样才能让它只搜索大学教科书,如以下链接所示?

http://www.amazon.co.uk/University-Textbooks/b/ref=amb_link_162814547_4?ie=UTF8&node=511914031&pf_rd_m=A3P5ROKL5A1OLE&pf_rd_s=left-1&pf_rd_r=0HCH1765DMFTPPTJ0QRG&pf_rd_t=101&pf_rd_p=361137207&pf_rd_i=266239

这是我的代码:

    public function amazonsearch($keywords)  {
    set_include_path(get_include_path() . PATH_SEPARATOR . 'application/libraries/Amazon');
    require_once 'Zend/Loader/StandardAutoloader.php';

    $autoloader = new Zend\Loader\StandardAutoloader(array(
        'namespaces' => array(
            'Zend'        => dirname(__FILE__) . '/Zend',
            'ZendRest'    => dirname(__FILE__) . '/ZendRest',
            'ZendService' => dirname(__FILE__) . '/ZendService',
        ),
        'fallback_autoloader' => true));

    $autoloader->register();

    $tag       = ''; // replace with your Amazon app ID
    $appId     = ''; // replace w/ your access key from https://portal.aws.amazon.com/gp/aws/securityCredentials
    $secretKey = '';
    $query  = new ZendService\Amazon\Query($appId, 'UK', $secretKey);
    $query->Category('Books')->Keywords($keywords)->AssociateTag($tag)->Page(10);
    $data['result'] = $query->search();
    /*var_dump( $data['result']);*/
    $this->load->view('development/amazonsearch',$data);
}
4

1 回答 1

1

我认为 ZendService\Amazon 不支持此功能 - 至少文档中没有任何内容。根据此页面很容易实现:http: //docs.aws.amazon.com/AWSECommerceService/latest/DG/BrowseNodeLookup.html

您可以尝试使用替代语法(http://framework.zend.com/manual/2.2/en/modules/zendservice.amazon.html#using-the-responsegroup-option)并传递 BrowseNode 参数 - 参数传递给查询所以也许它会起作用:

$amazon->itemSearch(array(
    'SearchIndex'   => 'All',
    'BrowseNode'    => '1000'
    'Keywords'      => $keywords,
    'ResponseGroup' => 'BrowseNodes,Medium'
));

然后替换特定类别的 BrowseNode 值。

顶级节点列表: http: //docs.aws.amazon.com/AWSECommerceService/latest/DG/BrowseNodeIDs.html

我没有测试过,因为我没有亚马逊 api 凭据。

于 2014-05-20T18:21:16.007 回答