defined('AWS_ASSOCIATE_TAG') or define('AWS_ASSOCIATE_TAG', 'ASSOCIATE TAG');
require '../lib/AmazonECS.class.php';
try {
    // get a new object with your API Key and secret key. Lang is optional.
    // if you leave lang blank it will be US.
    $amazonEcs = new AmazonECS(AWS_API_KEY, AWS_API_SECRET_KEY, 'de', AWS_ASSOCIATE_TAG);
    // If you are at min version 1.3.3 you can enable the requestdelay.
    // This is usefull to get rid of the api requestlimit.
    // 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);
            add_post_meta($postID, '_sku', $product->asin);
            add_post_meta($postID, '_price', $product->price);
            add_post_meta($postID, '_stock', $product->available);
        }
    }
} elseif (isset($_POST['getamazon'])) {
    require dirname(__FILE__) . '/../AmazonECS_133/Exeu-Amazon-ECS-PHP-Library-1867eaa/lib/AmazonECS.class.php';
    try {
        $awsapikey = get_option('awsapikey');
        $awsapisecretkey = get_option('awsapisecretkey');
        $awsassociatetag = get_option('awspa_associatetag');
        $markup = get_option('awspa_markup');
        $category = $_POST['category'];
        $catname = $category;
        $amazonEcs = new AmazonECS($awsapikey, $awsapisecretkey, 'com', $awsassociatetag);
        $response = $amazonEcs->category('All')->responseGroup('ItemAttributes,Offers,Images,Reviews')->search($category);
        $products = array();
        $i = 0;
        foreach ($response->Items as $item) {
            if (is_array($item)) {
                foreach ($item as $product) {
                    $prod = $product->ItemAttributes->Title;
                    $prodcode = $product->ASIN;
                    $listprice = number_format(floatval(preg_replace('/[\\$,]/', '', $product->ItemAttributes->ListPrice->FormattedPrice) * $markup), 2);
                    $avail = $product->Offers->TotalOffers;
                    $brand = $product->ItemAttributes->Brand;
                    $manufacturer = $product->ItemAttributes->Manufacturer;
                    $sku = $product->ItemAttributes->SKU;
                    $upc = $product->ItemAttributes->UPC;
                    $reviews = $product->ItemAttributes->CustomerReviews->IFrameURL;
                    $detailPageURL = $product->DetailPageURL;
Пример #3
0
require '../lib/AmazonECS.class.php';
try {
    // get a new object with your API Key and secret key. Lang is optional.
    // if you leave lang blank it will be US.
    $amazonEcs = new AmazonECS(AWS_API_KEY, AWS_API_SECRET_KEY, 'com', AWS_ASSOCIATE_TAG);
    // If you are at min version 1.3.3 you can enable the requestdelay.
    // This is usefull to get rid of the api requestlimit.
    // 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");
    $response = $amazonEcs->category('ALL')->search("iphone");
    //var_dump($response);exit;
    // from now on you want to have pure arrays as response
    $amazonEcs->returnType(AmazonECS::RETURN_TYPE_ARRAY);
    // searching again
    $response = $amazonEcs->search('Bud Spencer');
    echo "<pre>";
    print_r($response);
    exit;
    //    var_dump($response);exit;
    // 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);
    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.
    // I have to set back my responseGroup to e.g. Large then starting the lookup request:
    $response = $amazonEcs->responseGroup('Large')->lookup('383621640X');
    //var_dump($response);
    // If you want to use a nodeId combined with your search operation you can add the nodeId as parameter:
    // It is necessary to provide a category first.
    $response = $amazonEcs->category('Software')->responseGroup('Large')->search('PHP 5', 466484);
    //var_dump($response);
    // Searching something and returning some nodes found for this keyword.
    $response = $amazonEcs->responseGroup('BrowseNodes')->search('Visual Studio');
    //var_dump($response);
} catch (Exception $e) {
    echo $e->getMessage();
}
if ("cli" !== PHP_SAPI) {
    echo "</pre>";
}
Пример #5
0
if ($_REQUEST['search']) {
    header('Content-Type: application/json');
    $store = $_REQUEST['store'];
    $store = trim($store, ". ");
    //some people put ".co.jp" in the store so strip out any leading .
    $tag = $_REQUEST['affiliate'];
    if (!$tag) {
        $tag = AWS_ASSOCIATE_TAG;
    }
    //use my tag if one is not supplied by the client
    $searchquery = $_REQUEST['search'];
    $type = $_REQUEST['type'];
    //for future use, at the moment searches All could be DVD or Books or other categories
    //this is where the magic happens
    $amazonEcs = new AmazonECS(AWS_API_KEY, AWS_API_SECRET_KEY, $store, $tag);
    $response = $amazonEcs->category($type)->responseGroup('Medium')->search($searchquery);
    echo json_encode($response->Items);
    //magic over. The rest is just presenting a web page for curious people arriving with a browser
} else {
    ?>
<html>
<body>
<h1>Shopping Search</h1>
<p>This web service proxies the Amazon API for a Gnome Shell search provider An example call would be:</p>

<p><a href="https://products.libertus.co.uk/?search=pink%20bunnies%20pen&type=All&store=co.uk&affiliate=theopensou-21">http://products.libertus.co.uk/?search=pink%20bunnies%20pen&type=All&store=co.uk&affiliate=theopensou-21</a></p>
<p>The tool itself can be installed from <a href="https://extensions.gnome.org/extension/564/amazon-shopping/">the Gnome extension collection</a></p>
<p>This is a <a href="http://libertus.co.uk">Libertus Solutions</a> service. We are not interested in the search queries, most of the time they won't be logged or looked at
although we might from time to time do some sample logging to see how much it is used and whether we need to dedicate more server power to it.</p>
<p>You can read more about the development of this service <a href="http://www.theopensourcerer.com/2012/12/privacy-is-hard-lets-go-shopping/">here</a>
<a href="http://www.theopensourcerer.com/2012/12/she-sells-sea-shells/">here</a> and <a href="http://www.theopensourcerer.com/2012/12/shopping-lens-for-gnome-shell/">here</a></p>