php Zend Service Amazon -如何在子类别中搜索?

6l7fqoea  于 2023-02-28  发布在  PHP
关注(0)|答案(1)|浏览(138)

我正在使用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);
}
bqucvtff

bqucvtff1#

我不认为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
我没有测试过,因为我没有amazon api证书。

相关问题