Ejemplo n.º 1
0
function getARS($type, $parameters)
{
    $cache = cached($type, $parameters);
    if ($cache) {
        return $cache;
    } else {
        $ars = new AmazonResultSet();
        if ($type == 'asin') {
            $ars->ASINSearch(padASIN($parameters['asin']), $parameters['mode']);
        }
        if ($type == 'browse') {
            $ars->browseNodeSearch($parameters['browsenode'], $parameters['page'], $parameters['mode']);
        }
        if ($type == 'search') {
            $ars->keywordSearch($parameters['search'], $parameters['page'], $parameters['mode']);
        }
        cache($type, $parameters, $ars);
    }
    return $ars;
}
Ejemplo n.º 2
0
 function ASIN()
 {
     return padASIN($this->ASIN);
 }
Ejemplo n.º 3
0
 function ASINSearch($ASIN, $mode = 'books')
 {
     $this->type = 'ASIN';
     $this->ASIN = $ASIN;
     $this->mode = $mode;
     $ASIN = padASIN($ASIN);
     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['asin'] = $ASIN;
         $parameters['mode'] = $mode;
         $parameters['type'] = "heavy";
         $parameters['tag'] = $this->assocID;
         $parameters['devtag'] = $this->devTag;
         // perform actual soap query
         $result = $soap_proxy->AsinSearchRequest($parameters);
         if (isSOAPError($result)) {
             print_r($result);
             return false;
         }
         $this->products[0] = new Product($result['Details'][0]);
         $this->totalResults = 1;
         unset($soapclient);
         unset($soap_proxy);
     } else {
         // form URL and call parseXML to download and parse it
         $this->url = 'http://xml.amazon.com/onca/xml2?t=' . ASSOCIATEID . '&dev-t=' . DEVTAG . '&AsinSearch=' . $this->ASIN . '&type=heavy&f=xml';
         $this->parseXML();
     }
     return $this->products[0];
 }
 function ASIN()
 {
     if ($this->soap) {
         // we need to be careful that leadign 0s are not lost
         return padASIN($this->soap['Asin']);
     } else {
         return padASIN($this->nodes['ASIN']);
     }
 }
 function ASINSearch($ASIN, $mode = 'books')
 {
     $this->type = 'ASIN';
     $this->ASIN = $ASIN;
     $this->mode = $mode;
     $ASIN = padASIN($ASIN);
     $this->Service = "AWSECommerceService";
     $this->Operation = "ItemLookup";
     $this->AWSAccessKeyId = DEVTAG;
     $this->AssociateTag = ASSOCIATEID;
     $this->ResponseGroup = "Large";
     $this->IdType = "ASIN";
     $this->ItemId = $ASIN;
     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, 'IdType' => $this->IdType, 'ItemId' => $this->ItemId);
         $parameters = array('AWSAccessKeyId' => DEVTAG, 'AssociateTag' => ASSOCIATEID, 'Request' => array($request));
         // perform actual soap query
         $result = $soap_proxy->ItemLookup($parameters);
         if (isSOAPError($result)) {
             return false;
         }
         $this->products[0] = new Product($result['Items']['Item']);
         $this->totalResults = 1;
         unset($soapclient);
         unset($soap_proxy);
     } else {
         // form URL and call parseXML to download and parse it
         $this->url = "http://ecs.amazonaws.com/onca/xml?" . "Service=" . $this->Service . "&Operation=" . $this->Operation . "&AssociateTag=" . $this->AssociateTag . "&AWSAccessKeyId=" . $this->AWSAccessKeyId . "&ResponseGroup=" . $this->ResponseGroup . "&IdType=" . $this->IdType . "&ItemId=" . $this->ItemId;
         $this->parseXML();
     }
     return $this->products[0];
 }