Exemple #1
0
<?php

/**
 * Simple demonstration using PHP Class Library to consume Amazon Web Services
 */
/* Please replace this with your own amazon key
  You can retrieve this from http://aws.amazon.com */
$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";
Exemple #2
0
if (isset($_POST["clearcart"]) && $_POST["clearcart"] == "true") {
    $_SESSION["cart"] = NULL;
    unset($_SESSION["cart"]);
}
$error_message = "";
/* After the search operation invoked */
if ($operation == "search" && empty($asin)) {
    // retrive the user parameters
    $query = $_POST["query"];
    $key = $_SESSION["key"];
    $catagory = $_POST["catagory"];
    $page = isset($_POST["page"]) ? $_POST["page"] : "1";
    $catagory_arr[$catagory] = "selected=\"true\"";
    // and then call the service
    $amazon_client = new AmazonClient($key, "SOAP");
    $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);