Exemplo n.º 1
0
 function keywordSearch($search, $page, $mode = 'books')
 {
     if (METHOD == 'SOAP') {
         error_reporting(E_ALL & ~E_NOTICE);
         $soapclient = new soapclient('http://soap.amazon.com/schemas2/AmazonWebServices.wsdl', 'wsdl');
         $soap_proxy = $soapclient->getProxy();
         $parameters['mode'] = $mode;
         $parameters['page'] = $page;
         $parameters['type'] = "heavy";
         $parameters['tag'] = $this->assocID;
         $parameters['devtag'] = $this->devTag;
         $parameters['sort'] = '+salesrank';
         $parameters['keyword'] = $search;
         // perform actual soap request
         $result = $soap_proxy->KeywordSearchRequest($parameters);
         if (isSOAPError($result)) {
             return false;
         }
         foreach ($result['Details'] as $product) {
             $this->products[] = new Product($product);
         }
         $this->totalResults = $result['TotalResults'];
         unset($soapclient);
         unset($soap_proxy);
     } else {
         $this->type = 'search';
         $this->search = $search;
         $this->page = $page;
         $search = urlencode($search);
         $this->mode = $mode;
         $this->url = 'http://xml.amazon.com/onca/xml2?t=' . ASSOCIATEID . '&dev-t=' . DEVTAG . '&KeywordSearch=' . $search . '&mode=' . $this->mode . '&type=heavy&page=' . $this->page . '&sort=+salesrank&f=xml';
         $this->parseXML();
     }
     return $this->products;
 }
 function keywordSearch($search, $page, $mode = 'Books')
 {
     $this->Service = "AWSECommerceService";
     $this->Operation = "ItemSearch";
     $this->AWSAccessKeyId = DEVTAG;
     $this->AssociateTag = ASSOCIATEID;
     $this->ResponseGroup = "Large";
     $this->SearchIndex = $mode;
     $this->Keywords = $search;
     if (METHOD == 'SOAP') {
         $soapclient = new nusoap_client('http://ecs.amazonaws.com/AWSECommerceService/AWSECommerceService.wsdl', 'wsdl');
         $soap_proxy = $soapclient->getProxy();
         $request = array('Service' => $this->Service, 'Operation' => $this->Operation, 'ResponseGroup' => $this->ResponseGroup, 'SearchIndex' => $this->SearchIndex, 'Keywords' => $this->Keywords);
         $parameters = array('AWSAccessKeyId' => DEVTAG, 'AssociateTag' => ASSOCIATEID, 'Request' => array($request));
         // perform actual soap query
         $result = $soap_proxy->ItemSearch($parameters);
         if (isSOAPError($result)) {
             return false;
         }
         $this->totalResults = $result['TotalResults'];
         foreach ($result['Items']['Item'] as $product) {
             $this->products[] = new Product($product);
         }
         unset($soapclient);
         unset($soap_proxy);
     } else {
         $this->url = "http://ecs.amazonaws.com/onca/xml?" . "Service=" . $this->Service . "&Operation=" . $this->Operation . "&AssociateTag=" . $this->AssociateTag . "&AWSAccessKeyId=" . $this->AWSAccessKeyId . "&ResponseGroup=" . $this->ResponseGroup . "&SearchIndex=" . $this->SearchIndex . "&Keywords=" . $this->Keywords;
         $this->parseXML();
     }
     return $this->products;
 }