Ejemplo n.º 1
0
 function ajax_amazonjs_search()
 {
     // from http get
     $itemPage = @$_GET['ItemPage'];
     $id = @$_GET['ID'];
     $keywords = @$_GET['Keywords'];
     $searchIndex = @$_GET['SearchIndex'];
     $countryCode = @$_GET['CountryCode'];
     if (!empty($id)) {
         if (preg_match('/^https?:\\/\\//', $id)) {
             // parse ItemId from URL
             if (preg_match('/^https?:\\/\\/.+\\.amazon\\.([^\\/]+).+(\\/dp\\/|\\/gp\\/product\\/)([^\\/]+)/', $id, $matches)) {
                 //$domain = $matches[1];
                 $itemId = $matches[3];
             }
             if (!isset($itemId)) {
                 $keywords = $id;
             }
         } else {
             $itemId = $id;
         }
     }
     $amazonjs = new Amazonjs();
     $amazonjs->init();
     if (isset($itemId)) {
         $result = $amazonjs->itemlookup($countryCode, $itemId);
         die(json_encode($result));
     } else {
         $result = $amazonjs->itemsearch($countryCode, $searchIndex, $keywords, $itemPage);
         die(json_encode($result));
     }
 }
Ejemplo n.º 2
0
 function ajax_amazonjs_search()
 {
     $itemId = null;
     // from http get
     $itemPage = @$_GET['ItemPage'];
     $id = @$_GET['ID'];
     $keywords = @$_GET['Keywords'];
     $searchIndex = @$_GET['SearchIndex'];
     $countryCode = @$_GET['CountryCode'];
     if (!empty($id)) {
         if (preg_match('/^https?:\\/\\//', $id)) {
             if ($asin = self::parse_asin($id)) {
                 $itemId = $asin;
             } else {
                 // url string as query keyword
                 $keywords = $id;
             }
         } else {
             $itemId = $id;
         }
     } else {
         if (!empty($keywords)) {
             if (preg_match('/^https?:\\/\\//', $keywords)) {
                 if ($asin = self::parse_asin($keywords)) {
                     $itemId = $asin;
                 }
             }
         }
     }
     $amazonjs = new Amazonjs();
     $amazonjs->init();
     if (isset($itemId)) {
         $result = $amazonjs->itemlookup($countryCode, $itemId);
         die(json_encode($result));
     } else {
         $result = $amazonjs->itemsearch($countryCode, $searchIndex, $keywords, $itemPage);
         die(json_encode($result));
     }
 }