Exemplo n.º 1
0
$next_list_date = $n_date[1]['published_date'];
//var holder for output
$json = array('list_date' => $list_date, 'next_list_date' => $next_list_date, 'list_name' => $r_list_name, 'books' => []);
//SQL 2
$result = $mysqli->query("SELECT title, rank, author,publisher, rank_last_week, rank,book_image,publisher,isbn,weeks_on_list FROM ranks join books_ok on b_isbn=isbn where list_name = '" . $r_list_name . "' and published_date='" . $list_date . "' order by rank ");
while ($aditional = $result->fetch_assoc()) {
    //var_dump( $aditional);
    //echo $aditional['isbn'] . "<br>";
    // get image from cache
    $amz_img = $cache->get($aditional['isbn']);
    // $aditional is not an object, it is an array so following will not work
    // $aditional -> isbn
    // if image not in cache
    if ($amz_img == null) {
        // send api call
        $response = $amazonEcs->responseGroup('Images')->lookup($aditional['isbn']);
        // if api call successful
        // TODO: more tries to get image in cache based on $aditional['isbn'], like looking up similar isbns
        if (!isset($response->Items->Request->Errors)) {
            $amz_img = $response->Items->Item->LargeImage->URL;
            $cache->set($aditional['isbn'], $amz_img, 0);
        } else {
            // fallback and get image from google api
            $new_api = file_get_contents("https://www.googleapis.com/books/v1/volumes?q=isbn:" . $aditional['isbn']);
            $nvar = json_decode($new_api);
            if (isset($nvar->items[0]->volumeInfo->imageLinks->thumbnail)) {
                $amz_img = $nvar->items[0]->volumeInfo->imageLinks->thumbnail;
                $cache->set($aditional['isbn'], $amz_img, 0);
            }
        }
    }
 // It depends on your current associate status and it is disabled by default.
 // $amazonEcs->requestDelay(true);
 // for the new version of the wsdl its required to provide a associate Tag
 // @see https://affiliate-program.amazon.com/gp/advertising/api/detail/api-changes.html?ie=UTF8&pf_rd_t=501&ref_=amb_link_83957571_2&pf_rd_m=ATVPDKIKX0DER&pf_rd_p=&pf_rd_s=assoc-center-1&pf_rd_r=&pf_rd_i=assoc-api-detail-2-v2
 // you can set it with the setter function or as the fourth paramameter of ther constructor above
 $amazonEcs->associateTag(AWS_ASSOCIATE_TAG);
 // changing the category to DVD and the response to only images and looking for some matrix stuff.
 $response = $amazonEcs->category('DVD')->responseGroup('Large')->search("Matrix Revolutions");
 //var_dump($response);
 // from now on you want to have pure arrays as response
 $amazonEcs->returnType(AmazonECS::RETURN_TYPE_ARRAY);
 // searching again
 $response = $amazonEcs->search('Bud Spencer');
 //var_dump($response);
 // and again... Changing the responsegroup and category before
 $response = $amazonEcs->responseGroup('Small')->category('Books')->search('PHP 5');
 //var_dump($response);
 // category has been set so lets have a look for another book
 $response = $amazonEcs->search('MySql');
 //var_dump($response);
 // want to look in the US Database? No Problem
 $response = $amazonEcs->country('com')->search('MySql');
 //var_dump($response);
 // or Japan?
 $response = $amazonEcs->country('co.jp')->search('MySql');
 //var_dump($response);
 // Back to DE and looking for some Music !! Warning "Large" produces a lot of Response
 $response = $amazonEcs->country('de')->category('Music')->responseGroup('Small')->search('The Beatles');
 //var_dump($response);
 // Or doing searchs in a loop?
 for ($i = 1; $i < 4; $i++) {
/**
 * For a running Search Demo see: http://amazonecs.pixel-web.org
 */
if ("cli" !== PHP_SAPI) {
    echo "<pre>";
}
if (is_file('sampleSettings.php')) {
    include 'sampleSettings.php';
}
defined('AWS_API_KEY') or define('AWS_API_KEY', 'API KEY');
defined('AWS_API_SECRET_KEY') or define('AWS_API_SECRET_KEY', 'SECRET KEY');
defined('AWS_ASSOCIATE_TAG') or define('AWS_ASSOCIATE_TAG', 'ASSOCIATE TAG');
require '../lib/AmazonECS.class.php';
try {
    $amazonEcs = new AmazonECS(AWS_API_KEY, AWS_API_SECRET_KEY, 'DE', AWS_ASSOCIATE_TAG);
    // for the new version of the wsdl its required to provide a associate Tag
    // @see https://affiliate-program.amazon.com/gp/advertising/api/detail/api-changes.html?ie=UTF8&pf_rd_t=501&ref_=amb_link_83957571_2&pf_rd_m=ATVPDKIKX0DER&pf_rd_p=&pf_rd_s=assoc-center-1&pf_rd_r=&pf_rd_i=assoc-api-detail-2-v2
    // you can set it with the setter function or as the fourth paramameter of ther constructor above
    $amazonEcs->associateTag(AWS_ASSOCIATE_TAG);
    // Looking up multiple items
    $response = $amazonEcs->responseGroup('Large')->optionalParameters(array('Condition' => 'New'))->lookup('B0017TZY5Y, B004DULNPY');
    //var_dump($response);
    $response = $amazonEcs->responseGroup('Images')->lookup('B0017TZY5Y');
    //var_dump($response);
} catch (Exception $e) {
    echo $e->getMessage();
}
if ("cli" !== PHP_SAPI) {
    echo "</pre>";
}
Exemplo n.º 4
0
     //Only image, price, url and title are used in this demo
     $productId = $product['productBaseInfo']['productIdentifier']['productId'];
     $title = $product['productBaseInfo']['productAttributes']['title'];
     $productDescription = $product['productBaseInfo']['productAttributes']['productDescription'];
     //We take the 200x200 image, there are other sizes too.
     $productImage = array_key_exists('200x200', $product['productBaseInfo']['productAttributes']['imageUrls']) ? $product['productBaseInfo']['productAttributes']['imageUrls']['200x200'] : '';
     $sellingPrice = $product['productBaseInfo']['productAttributes']['sellingPrice']['amount'];
     $productUrl = $product['productBaseInfo']['productAttributes']['productUrl'];
     $productBrand = $product['productBaseInfo']['productAttributes']['productBrand'];
     $color = $product['productBaseInfo']['productAttributes']['color'];
     $productUrl = $product['productBaseInfo']['productAttributes']['productUrl'];
     $from = "Flipkart";
 } else {
     if ($response->Items->Item != NULL) {
         $asin = $response->Items->Item[$i]->ASIN;
         $response2 = $amazonEcs->responseGroup('Large')->lookup($asin);
         $productImage = $response2->Items->Item->MediumImage->URL;
         $sellingPrice = $response2->Items->Item->ItemAttributes->ListPrice->FormattedPrice;
         if ($sellingPrice == NULL) {
             $sellingPrice = $response2->Items->Item->OfferSummary->LowestNewPrice->FormattedPrice;
         }
         $title = $response2->Items->Item->ItemAttributes->Title;
         $productUrl = $response2->Items->Item->DetailPageURL;
         $from = "Amazon";
         $i += 1;
     }
     //print_r($productImage.'</br>'.$sellingPrice.'</br>'.$title.'</br>'.$productUrl);
 }
 $count++;
 //Setting up the table rows/columns for a 3x3 view.
 $end = 0;
<?php

include '../../settings.php';
try {
    $amazonEcs = new AmazonECS(AWS_API_KEY, AWS_API_SECRET_KEY, 'US');
    // First of all you have to set an another ResponseGroup. If not the request would not be successful
    // Possible Responsegroups: BrowseNodeInfo,MostGifted,NewReleases,MostWishedFor,TopSellers
    $amazonEcs->responseGroup('BrowseNodeInfo');
    // Then browse a node like this:  nodeId (See: http://docs.amazonwebservices.com/AWSECommerceService/2010-09-01/DG/index.html?BrowseNodeIDs.html)
    // For example: 542064 on German Amazon is: Software
    $response = $amazonEcs->browseNodeLookup(1000);
    print_r($response);
    // The response contains now some information about this Node and its children, ancestors etc.
    // So we picked out one noteId of the childelements: 408306 -> Programmierung (Programming).
    // Now we want to browse this node
    $response = $amazonEcs->responseGroup('TopSellers')->browseNodeLookup(1);
    print_r($response);
    // Picking out one childNodeId again
    // 466484 -> Programmiersprachen (Programming languages)
    $response = $amazonEcs->browseNodeLookup(466484);
    //var_dump($response);
    // I think its enough now.. the basics should be clear. You can browse deeper and deeper this way.
    // Now we want to display the TopSellers in this node.
    // So we have to change the responseGroup.
    $response = $amazonEcs->responseGroup('BrowseNodeInfo,TopSellers')->browseNodeLookup(466484);
    //var_dump($response);
    // This is compatible with the associateTag feature. Feel free to use it here.
    $response = $amazonEcs->associateTag(AWS_ASSOCIATE_TAG)->browseNodeLookup(466484);
    //var_dump($response);
    // At this moment when i'm writing this this ASIN: 383621640X is the TopSeller in this Node
    // So i want to fetch all Infos about it.
<?php

if ("cli" !== PHP_SAPI) {
    echo "<pre>";
}
if (is_file('sampleSettings.php')) {
    include 'sampleSettings.php';
}
defined('AWS_API_KEY') or define('AWS_API_KEY', 'API KEY');
defined('AWS_API_SECRET_KEY') or define('AWS_API_SECRET_KEY', 'SECRET KEY');
require '../lib/AmazonECS.class.php';
try {
    $amazonEcs = new AmazonECS(AWS_API_KEY, AWS_API_SECRET_KEY, 'DE');
    $response = $amazonEcs->responseGroup('Large')->similarityLookup('B0017TZY5Y');
    //var_dump($response);
    $response = $amazonEcs->responseGroup('Images')->similarityLookup('B0017TZY5Y');
    //var_dump($response);
} catch (Exception $e) {
    echo $e->getMessage();
}
if ("cli" !== PHP_SAPI) {
    echo "</pre>";
}
Exemplo n.º 7
0
<?php

echo "<pre>";
include 'settings/settings.php';
require 'lib/AmazonECS.class.php';
try {
    $ecs = new AmazonECS(AWS_API_KEY, AWS_API_SECRET_KEY, 'com', AWS_ASSOCIATE_TAG);
    $ecs->responseGroup('BrowseNodeInfo,TopSellers');
    $response = $ecs->browseNodeLookup(229534);
    echo print_r($response->BrowseNodes->BrowseNode->TopSellers->TopSeller[0]);
    $response = $ecs->responseGroup('Similarities')->lookup($response->BrowseNodes->BrowseNode->TopSellers->TopSeller[0]->ASIN);
    echo print_r($response);
} catch (Exception $e) {
    echo $e->getMessage();
}
echo "</pre>";
Exemplo n.º 8
0
const Aws_ID = "AKIAJ5TGZU744CQHFQFA";
// Identifiant
const Aws_SECRET = "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";
//Secret
const associateTag = "190571010520";
// AssociateTag
$client = new AmazonECS(Aws_ID, Aws_SECRET, 'FR', associateTag);
require 'include/header.php';
?>
    <div class="container">
        <br><br><br>
        <?php 
$asin = $_GET['ASIN'];
if ($asin != null) {
    //$response = $client->responseGroup('Large')->lookup($title);
    $response = $client->responseGroup('Large')->lookup($asin);
    $items = $response->Items;
    if (empty($response->Items->Item)) {
        echo "Le code ASIN est n'est pas ou plus valable.";
    } else {
        $item = $items->Item;
        echo '<h2>' . $item->ItemAttributes->Title . '</h2>';
        echo '<p><a href="' . $item->DetailPageURL . '" target="_blank">Lien Amazon</a></p>';
        //
        echo '<div class="row"><div class="col-lg-6">';
        echo '<br><p>Quelques informations:</p><br>';
        if (isset($item->ItemAttributes->Artist)) {
            echo "<p>Auteur : " . $item->ItemAttributes->Artist . "</p>";
        } else {
            echo "<p>Auteur : Aucune information</p>";
        }
Exemplo n.º 9
0
function wfGetAmazonAWS($query, $callback)
{
    $AWS_API_KEY = '0G5V6FHQXQ1JREGFZVR2';
    $AWS_API_SECRET_KEY = '8oxghQ9SKjZCnGc8tvjMyVR0aAj7rRJfw7w99cRK';
    $AWS_ASSOCIATE_TAG = 'zerosixtycorp-20';
    require '../common/AmazonECS.class.php';
    $amazonEcs = new AmazonECS($AWS_API_KEY, $AWS_API_SECRET_KEY, 'com', $AWS_ASSOCIATE_TAG);
    $response = $amazonEcs->responseGroup('Small,Images')->search($query);
    //    	var_dump($response);exit;
    if ($callback) {
        return $callback . "(" . $response . ")";
    } else {
        return $response;
    }
}