Exemple #1
0
$key = "your_amazon_key";
/* creating the AmazonClient object */
require_once "AmazonClient.php";
$amazon_client = new AmazonClient($key, "SOAP");
/************************************************************************/
/* Invoking the ItemSearch operation */
$items = $amazon_client->ItemSearch("Web Services Sanjiva", "Books");
foreach ($items->Item as $item) {
    echo $item->ASIN . ". ";
    echo $item->ItemAttributes->Title . " - ";
    #echo $item->DetailPageURL. " - ";
    echo $item->ItemAttributes->Author . "\n";
}
/************************************************************************/
/* Invoking the ItemLookup operation */
$lookups = $amazon_client->ItemLookup("0131488740");
echo $lookups->Item->ASIN . ". ";
echo $lookups->Item->ItemAttributes->Title . " - ";
echo $lookups->Item->ItemAttributes->Author . "\n";
/************************************************************************/
/* Invoking the CartCreate operation */
$cart = $amazon_client->CartCreate(array("0131488740" => 5));
echo $cart->CartId . " - ";
echo $cart->CartItems->SubTotal->FormattedPrice . "\n";
echo "HMAC: " . $cart->HMAC . "\n";
foreach ($cart->CartItems->CartItem as $item) {
    echo "Item: {$item->CartItemId} - {$item->Title}.\n";
}
echo $cart->PurchaseURL . "\n";
/************************************************************************/
/* Invoking the CartModify operation */
Exemple #2
0
    $searched_items = $amazon_client->ItemSearch($query, $catagory, $page);
    if ($searched_items->OperationRequest != NULL && $searched_items->OperationRequest->Errors != NULL && $searched_items->OperationRequest->Errors->Error != NULL) {
        $error_message = trim($searched_items->OperationRequest->Errors->Error->Message . "");
    } else {
        if ($searched_items->Items != NULL && $searched_items->Items->Request != NULL && $searched_items->Items->Request->Errors != NULL && $searched_items->Items->Request->Errors->Error != NULL) {
            $error_message = trim($searched_items->Items->Request->Errors->Error->Message . "");
        } else {
            $searched_items = $searched_items->Items;
        }
    }
}
/* After an item is selected to add */
if (!empty($asin) && $operation != "add") {
    $key = $_SESSION["key"];
    $amazon_client = new AmazonClient($key, "SOAP");
    $item_lookups = $amazon_client->ItemLookup($asin);
    if ($item_lookups->Request != NULL && $item_lookups->Request->Errors != NULL && $item_lookups->Request->Errors->Error != NULL) {
        $error_message = trim($item_lookups->Request->Errors->Error->Message . "");
    } else {
        $item_lookups = $item_lookups->Items;
    }
}
/* When the adding is really happening */
$cart = $_SESSION["cart"];
$is_add_valid = "True";
if ($operation == "add") {
    $number = $_POST["number"];
    $key = $_SESSION["key"];
    if (!isset($cart) || empty($cart)) {
        /* we have to create a cart */
        $amazon_client = new AmazonClient($key, "SOAP");