Пример #1
0
<?php

require_once realpath(dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR . 'indexer.php');
use nzedb\db\Settings;
use libs\AmazonProductAPI;
// Test if your amazon keys are working.
$pdo = new Settings();
$pubkey = $pdo->getSetting('amazonpubkey');
$privkey = $pdo->getSetting('amazonprivkey');
$asstag = $pdo->getSetting('amazonassociatetag');
$obj = new AmazonProductAPI($pubkey, $privkey, $asstag);
$e = null;
try {
    $result = $obj->searchProducts("Adriana Koulias The Seal", AmazonProductAPI::BOOKS, "TITLE");
} catch (Exception $e) {
    $result = false;
}
if ($result !== false) {
    print_r($result);
    exit($pdo->log->header("\nLooks like it is working alright."));
} else {
    print_r($e);
    exit($pdo->log->error("\nThere was a problem attemtping to query amazon. Maybe your keys or wrong, or you are being throttled.\n"));
}
Пример #2
0
 /**
  * @param $title
  *
  * @return bool|mixed
  */
 public function fetchAmazonProperties($title)
 {
     $result = false;
     $obj = new AmazonProductAPI($this->pubkey, $this->privkey, $this->asstag);
     // Try Music category.
     try {
         $result = $obj->searchProducts($title, AmazonProductAPI::MUSIC, "TITLE");
     } catch (\Exception $e) {
         // Empty because we try another method.
     }
     // Try MP3 category.
     if ($result === false) {
         usleep(700000);
         try {
             $result = $obj->searchProducts($title, AmazonProductAPI::MP3, "TITLE");
         } catch (\Exception $e) {
             // Empty because we try another method.
         }
     }
     // Try Digital Music category.
     if ($result === false) {
         usleep(700000);
         try {
             $result = $obj->searchProducts($title, AmazonProductAPI::DIGITALMUS, "TITLE");
         } catch (\Exception $e) {
             // Empty because we try another method.
         }
     }
     // Try Music Tracks category.
     if ($result === false) {
         usleep(700000);
         try {
             $result = $obj->searchProducts($title, AmazonProductAPI::MUSICTRACKS, "TITLE");
         } catch (\Exception $e) {
             // Empty because we exhausted all possibilities.
         }
     }
     return $result;
 }
Пример #3
0
 /**
  * @param $title
  *
  * @return bool|mixed
  */
 public function fetchAmazonProperties($title)
 {
     $obj = new AmazonProductAPI($this->pubkey, $this->privkey, $this->asstag);
     try {
         $result = $obj->searchProducts($title, AmazonProductAPI::BOOKS, 'TITLE');
     } catch (\Exception $e) {
         $result = false;
     }
     return $result;
 }