示例#1
0
<?php

//API reference is @ 	http://tarzan-aws.com/docs/2.0/files/aaws-class-php.html
//								http://tarzan-aws.com/docs/2.0/files/aaws-class-php.html#AmazonAAWS.__construct
//public function item_search
//(
//	$keywords,
//	$opt  =  null,
//	$locale  =  AAWS_LOCALE_US
//)
// Include the main Tarzan class
require_once 'tarzan/tarzan.class.php';
// Set the headers to plain text with a UTF-8 character set (so that we can read the output more easily).
header('Content-type: text/html; charset=utf-8');
// Instantiate a new AmazonAAWS object.
$aws = new AmazonAAWS();
// reference: http://tarzan-aws.com/docs/2.0/files/aaws-class-php.html#AmazonAAWS.item_search
$result = $aws->item_search("Cocoa Programming");
// Check that the last request was successful. (HTTP status code 200 means everything was okay.)
if ($result->isOK()) {
    print_r($result);
} else {
    print_r($create);
    exit('Ka-BOOM!');
}
示例#2
0
<?php

session_start();
require_once 'includes/tarzan.class.php';
$searchIndex = isset($_POST['searchIndex']) ? $_POST['searchIndex'] : 'all';
$keywords = isset($_POST['keywords']) ? $_POST['keywords'] : 'all';
$page = isset($_POST['page']) ? $_POST['page'] : 1;
$aaws = new AmazonAAWS('AKIAITRZR5LXLG4QILTA', '0Z/hDsa8nnvqP/wa+/ylHi5GI0NemY5lGf6X9J+7', 'ipowerhostcou-20');
$opt = array('ItemPage' => $page, 'Condition' => 'New', 'ResponseGroup' => 'OfferSummary,ItemAttributes,SalesRank,Images,OfferListings', 'SearchIndex' => $searchIndex);
$get = $aaws->item_search($keywords, $opt);
$i = 0;
foreach ($get->body->Items->Item as $item) {
    $lprice = (int) $item->ItemAttributes->ListPrice->Amount;
    $lowest = (int) $item->OfferSummary->LowestNewPrice->Amount;
    if (!$lowest && !$lprice) {
        continue;
    }
    if ($lprice > 0) {
        // item has listprice
        $d_price = number_format($lprice / 100, 2);
        $s_ccode = (string) $item->ItemAttributes->ListPrice->CurrencyCode;
    } else {
        $d_price = '';
        $s_ccode = (string) $item->OfferSummary->LowestNewPrice->CurrencyCode;
    }
    if ($lowest > 0) {
        // item has lowest price
        $d_lowest = number_format($lowest / 100, 2);
        $i_discount = '';
        if ($lprice > 0) {
            $i_discount = ($lprice - $lowest) / $lprice;
示例#3
0
<?php

session_start();
require_once 'includes/tarzan.class.php';
function format_number($num)
{
    return number_format($num / 100, 2);
}
// format_number
$item_id = $_POST['asin'];
$aaws = new AmazonAAWS('AKIAITRZR5LXLG4QILTA', '0Z/hDsa8nnvqP/wa+/ylHi5GI0NemY5lGf6X9J+7', 'ipowerhostcou-20');
$opt = array('Condition' => 'New', 'ResponseGroup' => 'EditorialReview,OfferSummary,ItemAttributes,SalesRank,Images,OfferListings,Offers,Reviews');
$get = $aaws->item_lookup($item_id, $opt);
$i = 0;
$item = $get->body->Items->Item;
$lprice = (int) $item->ItemAttributes->ListPrice->Amount;
$lowest = (int) $item->OfferSummary->LowestNewPrice->Amount;
if (!$lowest && !$lprice) {
    continue;
}
if ($lprice > 0) {
    // item has listprice
    $d_price = number_format($lprice / 100, 2);
    $s_ccode = (string) $item->ItemAttributes->ListPrice->CurrencyCode;
} else {
    $d_price = '';
    $s_ccode = (string) $item->OfferSummary->LowestNewPrice->CurrencyCode;
}
if ($lowest > 0) {
    // item has lowest price
    $d_lowest = number_format($lowest / 100, 2);
示例#4
0
<?php

session_start();
require_once 'includes/tarzan.class.php';
$item_id = isset($_POST['asin']) ? $_POST['asin'] : '';
$offer_id = isset($_POST['offerId']) ? $_POST['offerId'] : '';
if (!$offer_id) {
    // without offer id? no problem, use ASIN
    $opt = array('Item.1.ASIN' => $item_id, 'Item.1.Quantity' => 1);
} else {
    $opt = null;
}
/*$opt  = array(
      'ResponseGroup' => 'CartSimilarities'
  );*/
$aaws = new AmazonAAWS('AKIAITRZR5LXLG4QILTA', '0Z/hDsa8nnvqP/wa+/ylHi5GI0NemY5lGf6X9J+7', 'ipowerhostcou-20');
if (empty($_SESSION['cartId'])) {
    // no session found
    if (isset($_POST['getcart'])) {
        // no session how to get cart?
        exit('0');
    }
    // create new cart
    $get = $aaws->cart_create($offer_id, $opt);
    $cart = $get->body->Cart;
    $_SESSION['cartId'] = (string) $cart->CartId;
    $_SESSION['hmac'] = (string) $cart->HMAC;
} else {
    if (isset($_POST['getcart'])) {
        // retrieve items from existing cart
        $get = $aaws->cart_get($_SESSION['cartId'], $_SESSION['hmac'], '');