#native_company# #native_desc#
#native_cta#

Amazon Web Services 4.0-Beta API Class

By Jason Ragsdale
on September 2, 2004

Version: 0.1

Type: Full Script

Category: Other

License: GNU General Public License

Description: This is a API class to interface with the new AWS 4.0 Beta interface. This script requires CURL, SimpleXML, and PHP5.

:::::::BEGIN aws4.inc.php:::::::::::::::
<?
/**
*
* aws4.inc.php Amazon.com Webservices API for version 4.0-Beta Version: 0.1
* by Jason Ragsdale (jrags (at) jasrags (dot) net)
* 
*   This program is free software; you can redistribute it and/or modify
*   it under the terms of the GNU General Public License as published by
*   the Free Software Foundation; either version 2 of the License, or
*   (at your option) any later version.
*
*   This program is distributed in the hope that it will be useful,
*   but WITHOUT ANY WARRANTY; without even the implied warranty of
*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*   GNU General Public License for more details.
*
*   You should have received a copy of the GNU General Public License
*   along with this program; if not, write to the Free Software
*   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*
*/

class aws {

    public  $Debug            = false;
    protected $baseURL          = '';
    protected $Country          = 'US';                     //Default to US
    protected $Service          = 'AWSProductData';         //This is the only Service option at this time
    protected $SubscriptionId   = '[YourIdHere]';           //Enter your SubscriptionId here, You can register for one at http://www.amazon.com/gp/aws/sdk/104-3261299-9963915
    protected $Operation        = 'ItemSearch';             //Your default operation
    protected $SearchIndex      = '';
    protected $Keywords         = '';
    protected $Title            = '';
    protected $Power            = '';
    protected $Artist           = '';
    protected $Author           = '';
    protected $Actor            = '';
    protected $Director         = '';
    protected $AudienceRating   = '';
    protected $Manufacturer     = '';
    protected $MusicLabel       = '';
    protected $Composer         = '';
    protected $Publisher        = '';
    protected $Brand            = '';
    protected $Conductor        = '';
    protected $Orchestra        = '';
    protected $TextStream       = '';
    protected $ItemPage         = '';
    protected $Sort             = '';
    protected $City             = '';
    protected $Cuisine          = '';
    protected $Neighborhood     = '';
    protected $MinimumPrice     = '';
    protected $MaximumPrice     = '';
    protected $MerchantId       = '';
    protected $Condition        = '';
    protected $DeliveryMethod   = '';
    protected $AssociateTag     = '';
    protected $Style            = '';
    protected $ContentType      = '';
    protected $InputContentEncoding = '';
    protected $Validate         = '';
    protected $Version          = '';
    protected $XMLEscaping      = '';
    protected $ResponseGroup    = '';
    protected $Result           = '';
    
	function aws() {
		
	}
	
	/**
	* Wed Sep 01 11:10:48 CDT 2004 11:10:48 - Ragsdale, Jason
	*
	* setBaseURL must be called when starting a new query.
	*
	*/
	function setBaseURL()
	{
	    /**
	    * Tue Aug 31 16:04:50 CDT 2004 16:04:50 - Ragsdale, Jason
	    *
	    * Valid Country Codes for the base URL are:
	    * US: United States
	    * UK: United Kingdom
	    * DE: Germany
	    * JP: Japan
	    *
	    */
	    
		if ($this->Country == 'US')
		  $this->baseURL = 'http://aws-beta.amazon.com/onca/xml?Service='.$this->Service;
		if ($this->Country == 'UK')
		  $this->baseURL = 'http://aws-beta.amazon.co.uk/onca/xml?Service='.$this->Service;
		if ($this->Country == 'DE')
		  $this->baseURL = 'http://aws-beta.amazon.de/onca/xml?Service='.$this->Service;
		if ($this->Country == 'JP')
		  $this->baseURL = 'http://aws-beta.amazon.co.jp/onca/xml?Service='.$this->Service;
		  
	}
	
	function setCountry($Country)
	{
	    /**
	    * Wed Sep 01 11:11:58 CDT 2004 11:11:58 - Ragsdale, Jason
	    *
	    * Use this to set the country you are pulling results for.
	    *
	    * Country Options:
	    * US (Default)
	    * UK
	    * DE
	    * JP
	    *
	    */
		$this->Country = $Country;
	}
	
	function getCountry()
	{
		return $this->Country;
	}
	
	function assembleURL()
	{
	    /**
	    * Tue Aug 31 16:06:47 CDT 2004 16:06:47 - Ragsdale, Jason
	    *
	    * This function will be called form the fetch method to make sure our URL is valid.
	    *
	    */
	    
	    if ($this->SubscriptionId)
	       $this->baseURL .= '&SubscriptionId='.$this->SubscriptionId;
	    if ($this->Operation)
	       $this->baseURL .= '&Operation='.$this->Operation;
	    if ($this->SearchIndex)
	       $this->baseURL .= '&SearchIndex='.$this->SearchIndex;
	    if ($this->Keywords)
	       $this->baseURL .= '&Keywords='.$this->Keywords;
	    if ($this->Title)
	       $this->baseURL .= '&Title='.$this->Title;
	    if ($this->Power)
	       $this->baseURL .= '&Power='.$this->Power;
	    if ($this->Artist)
	       $this->baseURL .= '&Artist='.$this->Artist;
	    if ($this->Author)
	       $this->baseURL .= '&Author='.$this->Author;
	    if ($this->Actor)
	       $this->baseURL .= '&Actor='.$this->Actor;
	    if ($this->Director)
	       $this->baseURL .= '&Director='.$this->Director;
	    if ($this->AudienceRating)
	       $this->baseURL .= '&AudienceRating='.$this->AudienceRating;
	    if ($this->Manufacturer)
	       $this->baseURL .= '&Manufacturer='.$this->Manufacturer;
	    if ($this->MusicLabel)
	       $this->baseURL .= '&MusicLabel='.$this->MusicLabel;
	    if ($this->Composer)
	       $this->baseURL .= '&Composer='.$this->Composer;
	    if ($this->Publisher)
	       $this->baseURL .= '&Publisher='.$this->Publisher;
	    if ($this->Brand)
	       $this->baseURL .= '&Brand='.$this->Brand;
	    if ($this->Conductor)
	       $this->baseURL .= '&Conductor='.$this->Conductor;
	    if ($this->Orchestra)
	       $this->baseURL .= '&Orchestra='.$this->Orchestra;
	    if ($this->TextStream)
	       $this->baseURL .= '&TextStream='.$this->TextStream;
	    if ($this->ItemPage)
	       $this->baseURL .= '&ItemPage='.$this->ItemPage;
	    if ($this->Sort)
	       $this->baseURL .= '&Sort='.$this->Sort;
	    if ($this->City)
	       $this->baseURL .= '&City='.$this->City;
	    if ($this->Cuisine)
	       $this->baseURL .= '&Cuisine='.$this->Cuisine;
	    if ($this->Neighborhood)
	       $this->baseURL .= '&Neighborhood='.$this->Neighborhood;
	    if ($this->MinimumPrice)
	       $this->baseURL .= '&MinimumPrice='.$this->MinimumPrice;
	    if ($this->MaximumPrice)
	       $this->baseURL .= '&MaximumPrice='.$this->MaximumPrice;
	    if ($this->MerchantId)
	       $this->baseURL .= '&MerchantId='.$this->MerchantId;
	    if ($this->Condition)
	       $this->baseURL .= '&Condition='.$this->Condition;
	    if ($this->DeliveryMethod)
	       $this->baseURL .= '&DeliveryMethod='.$this->DeliveryMethod;
	    if ($this->AssociateTag)
	       $this->baseURL .= '&AssociateTag='.$this->AssociateTag;
	    if ($this->Style)
	       $this->baseURL .= '&Style='.$this->Style;
	    if ($this->ContentType)
	       $this->baseURL .= '&ContentType='.$this->ContentType;
	    if ($this->InputContentEncoding)
	       $this->baseURL .= '&InputContentEncoding='.$this->InputContentEncoding;
	    if ($this->Validate)
	       $this->baseURL .= '&Validate='.$this->Validate;
	    if ($this->Version)
	       $this->baseURL .= '&Version='.$this->Version;
	    if ($this->XMLEscaping)
	       $this->baseURL .= '&XMLEscaping='.$this->XMLEscaping;
	    if ($this->ResponseGroup)
	       $this->baseURL .= '&ResponseGroup='.$this->ResponseGroup;
	    
	    return;
	}
	
	function fetch()
	{
	    /**
	    * Tue Aug 31 16:09:19 CDT 2004 16:09:19 - Ragsdale, Jason
	    *
	    * This is the function to send the request to amazon Via CURL
	    * and store the XML result.
	    *
	    */
	    //Assemble the URL before fetching it.
	    $this->assembleURL();
	    
	    //Create our local FilePointer and fetch the XML into it.
        $this->fp = fopen(md5($this->baseURL), 'w');
		$this->ch = curl_init();

        curl_setopt($this->ch, CURLOPT_URL, $this->baseURL);
        curl_setopt($this->ch, CURLOPT_HEADER, 0);
        curl_setopt($this->ch, CURLOPT_FILE, $this->fp);
        curl_setopt($this->ch, CURLOPT_TIMEOUT, 10);

        $this->result = curl_exec($this->ch);
        curl_close($this->ch);
        
        fclose($this->fp);
        
        //Load the XML from the temp file.
        $this->xml = simplexml_load_file(md5($this->baseURL));
        
        //Remove the temp file after load of the xml data
        unlink(md5($this->baseURL));
        
        //Check the XML for errors, if so, throw.
        try {
            $this->checkXmlError();
        } catch (Exception $e) {
            echo $e->getMessage();
        }
	}
	
	
	function getBaseURL()
	{
		return $this->baseURL;
	}
	
	function setService($Service)
	{
	    /**
	    * Wed Sep 01 11:09:02 CDT 2004 11:09:02 - Ragsdale, Jason
	    *
	    * The service parameter is required for all AWS Requests. It should always be set to AWSProductData.
	    *
	    * Service Options:
        * AWSProductData
        *
	    */
		$this->Service = $Service;
	}
	
	function getService()
	{
		return $this->Service;
	}
	
	function setSubscriptionId($SubscriptionId)
	{
	    /**
	    * Wed Sep 01 11:08:06 CDT 2004 11:08:06 - Ragsdale, Jason
	    *
	    * The SubscriptionId parameter must be included in every AWS request. The value of 
	    * this parameter must be the subscription ID you are assigned when you sign up to use 
	    * AWS. Your subscription ID is connected to your AWS developer account and represents 
	    * a free subscription to AWS.
	    * 
	    * SubscriptionId Options:
	    * Your Amazon-assigned subscription ID
	    *
	    */
		$this->SubscriptionId = $SubscriptionId;
	}
	
	function getSubscriptionId()
	{
		return $this->SubscriptionId;
	}
	
	function setOperation($Operation)
	{
	    /**
	    * Wed Sep 01 11:07:01 CDT 2004 11:07:01 - Ragsdale, Jason
	    *
	    * Use the Operation parameter to specify the name of the operation you would like 
	    * to call. To access the ItemSearch operation, set the Operation parameter to ItemSearch.
	    * 
	    * Operation Options:
	    * ItemSearch
	    * ItemLookup
	    * SimilarityLookup
	    *
	    */
		$this->Operation = $Operation;
	}
	
	function getOperation()
	{
		return $this->Operation;
	}
	
	function setSearchIndex($SearchIndex)
	{
	    /**
	    * Tue Aug 31 16:10:13 CDT 2004 16:10:13 - Ragsdale, Jason
	    *
	    * Use the SearchIndex parameter to specify the Amazon store you want products from. 
	    * The list of available SearchIndex values, listed by locale, can be found on the 
	    * search index values page.
        * 
        * If SearchIndex is set to "MusicTracks," the number of items returned is the total 
        * number of tracks rather than the number of ASINs in which the tracks were found.
        * 
        * However, ItemSearch requests in the MusicTracks index return information based on 
        * ASIN, and AWS never repeats an ASIN in a response. Because of these two facts, the 
        * TotalResults value does not reflect the actual number of Item elements in the response 
        * when two or more tracks are from the same ASIN.
        * 
        * Similarly, if two or more tracks are from the same ASIN, it is possible that the TotalPages 
        * value is greater than the actual number of pages.

	    * Search index options:
	    * Blended              (US UK DE JP)
	    * Books                (US UK DE JP)
	    * ForeignBooks         (      DE JP)
	    * Music                (US UK DE JP)
	    * Classical            (US UK DE JP)
	    * DigitalMusic         (US         )
	    * MusicTracks          (US UK DE JP)
	    * DVD                  (US UK DE JP)
	    * Video                (US UK DE JP)
	    * VHS                  (US UK DE JP)
	    * Toys                 (US UK      )
	    * Apparel              (US         )
	    * Baby                 (US         )
	    * PCHardware           (US    DE   )
	    * VideoGames           (US UK DE JP)
	    * Software             (US UK DE JP)
	    * SoftwareVideoGames   (   UK DE   )
	    * Electronics          (US UK DE JP)
	    * Photo                (US    DE   )
	    * Tools                (US    DE   )
	    * OfficeProducts       (US         )
	    * Magazines            (US    DE   )
	    * SportingGoods        (US         )
	    * OutdoorLiving        (US UK DE   )
	    * Kitchen              (US UK DE JP)
	    * HomeGarden           (   UK DE   )
	    * GourmetFood          (US         )
	    * HealthPersonalCare   (US UK DE   )
	    * Wireless             (US         )
	    * Wireless Accessories (US         )
	    * Miscellaneous        (US         )
	    * Restaurants          (US         )
	    * Jewelry              (US         )
	    *
	    */
		$this->SearchIndex = $SearchIndex;
	}
	
	function getSearchIndex()
	{
		return $this->SearchIndex;
	}
	
	function setKeywords($Keywords)
	{
	    /**
	    * Wed Sep 01 11:04:29 CDT 2004 11:04:29 - Ragsdale, Jason
	    *
	    * Use the Keywords parameter to refine your item search based on specific 
	    * words or phrases. AWS Product data will match the word or phrase you 
	    * include in your request against various product fields, including product 
	    * title, author, artist, description, manufacturer, etc.
	    *
	    * Keywords Options:
	    * A Keywords String
	    * 
	    */
		$this->Keywords = urlencode($Keywords);
	}
	
	function getKeywords()
	{
		return $this->Keywords;
	}
	
	function setResponseGroup($ResponseGroup)
	{
	    /**
	    * Tue Aug 31 16:18:34 CDT 2004 16:18:34 - Ragsdale, Jason
	    *
	    * Use this parameter to specify which response group(s), or group(s) of 
	    * data elements, you would like AWS to return to you.
        * 
        * For REST requests, the ResponseGroup parameter can be a single value 
        * or a comma-delimited list.
        * 
	    * Response Group Options:
	    * BrowseNodes
	    * Cart
	    * CartSimilarities
	    * CustomerFull
	    * CustomerInfo
	    * CustomerLists
	    * CustomerReviews
	    * EditorialReview
	    * Help
	    * Images
	    * ItemAttributes
	    * ItemIds
	    * Large
	    * ListFull
	    * ListInfo
	    * ListItems
	    * ListmaniaLists
	    * ListMinimum
	    * Medium
	    * OfferFull
	    * Offers
	    * OfferSummary
	    * Request
	    * Reviews
	    * SalesRank
	    * Seller
	    * SellerListing
	    * Similarities
	    * Small
	    * Tracks
	    * TransactionDetails
	    * VariationMinimum
	    * Variations
	    * VariationSummary
	    *
	    */
		$this->ResponseGroup = $ResponseGroup;
	}
	
	function getResponseGroup()
	{
		return $this->ResponseGroup;
	}
	
	function setTitle($Title)
	{
	    /**
	    * Wed Sep 01 11:03:52 CDT 2004 11:03:52 - Ragsdale, Jason
	    *
	    * Use the Title parameter when you want to query against product titles only. 
	    * You may use all or part of a title in your query.
        * 
        * When SearchIndex equals MusicTracks, the Title parameter allows you to search 
        * by song title.
        *
        * Title Options:
        * A Title String 
	    *
	    */
		$this->Title = $Title;
	}
	
	function getTitle()
	{
		return $this->Title;
	}
	
	function setPower($Power)
	{
	    /**
	    * Wed Sep 01 11:02:38 CDT 2004 11:02:38 - Ragsdale, Jason
	    *
	    * Use the Power parameter to perform book searches on Amazon.com using a 
	    * complex query string.
        * 
        * For example the query "author:ambrose" returns a list of books that include 
        * "Ambrose" in the author name. A query of "subject:history and (spain or mexico) 
        * and not military and language:spanish" would return a list of books in the 
        * Spanish language on the subject of either Spanish or Mexican history, excluding 
        * all items with military in their subject.
        * 
        * Query keys that may be used to build Power queries include: asin, author, 
        * author-exact, author-begins, keywords, keywords-begin, language, publisher, 
        * subject, subject-words-begin, subject-begins, title, title-words-begin, and 
        * title-begins.
        * 
        * The Power parameter can only be used when SearchIndex equals Books.
        * 
        * Please see this page on Amazon for more information about Power search: 
        * http://www. amazon.com/exec/obidos/ats-query-page#powersearch.
        * 
        * Power Options:
        * A Power Query String
	    *
	    */
		$this->Power = $Power;
	}
	
	function getPower()
	{
		return $this->Power;
	}
	
	function setArtist($Artist)
	{
	    /**
	    * Wed Sep 01 11:01:42 CDT 2004 11:01:42 - Ragsdale, Jason
	    *
	    * Use the Artist parameter to refine your search by Artist name. 
	    * You may use all or part of an Artist's name in your query.
	    * 
	    * Artist Option:
	    * An Artist Name String
	    *
	    */
		$this->Artist = $Artist;
	}
	
	function getArtist()
	{
		return $this->Artist;
	}
	
	function setAuthor($Author)
	{
	    /**
	    * Wed Sep 01 11:01:39 CDT 2004 11:01:39 - Ragsdale, Jason
	    *
	    * Use the Author parameter to refine your search by Author name. 
	    * You may use all or part of an Author's name in your query.
	    * 
	    * Author Option:
	    * An Author Name String
	    *
	    */
		$this->Author = $Author;
	}
	
	function getAuthor()
	{
		return $this->Author;
	}
	
	function setActor($Actor)
	{
	    /**
	    * Wed Sep 01 11:01:37 CDT 2004 11:01:37 - Ragsdale, Jason
	    *
	    * Use the Actor parameter to refine your search by Actor name. 
	    * You may use all or part of an Actor's name in your query.
	    * 
	    * Actor Option:
	    * An Actor Name String
	    *
	    */
		$this->Actor = $Actor;
	}
	
	function getActor()
	{
		return $this->Actor;
	}
	
	function setDirector($Director)
	{
	    /**
	    * Wed Sep 01 11:01:34 CDT 2004 11:01:34 - Ragsdale, Jason
	    *
	    * Use the Director parameter to refine your search by Director name. 
	    * You may use all or part of an Director's name in your query.
	    * 
	    * Director Option:
	    * An Director Name String
	    *
	    */
		$this->Director = $Director;
	}
	
	function getDirector()
	{
		return $this->Director;
	}
	
	function setAudienceRating($AudienceRating)
	{
	    /**
	    * Wed Sep 01 10:59:57 CDT 2004 10:59:57 - Ragsdale, Jason
	    *
	    * Use the AudienceRating parameter to filter movie product search results 
	    * by the expected audience maturity level. Amazon.com values are based 
	    * upon MPAA (Motion Picture Association of America) ratings. Amazon.de 
	    * values are based upon age. You may specify one or more values in a 
	    * comma-separated list in a REST request or using multiple elements in 
	    * a SOAP request.
	    * 
	    * AudienceRating Options:
	    *      Amazon.com Values:
	    * G
	    * PG
	    * PG-13
	    * R
	    * NC-17
	    * NR
	    * Unrated
	    *      Amazon.de Values:
	    * 6
	    * 12
	    * 16
	    *
	    */
		$this->AudienceRating = $AudienceRating;
	}
	
	function getAudienceRating()
	{
		return $this->AudienceRating;
	}
	
	function setManufacturer($Manufacturer)
	{
	    /**
	    * Wed Sep 01 10:59:37 CDT 2004 10:59:37 - Ragsdale, Jason
	    *
	    * Use the Manufacturer parameter to refine your search by Manufacturer name. 
	    * You may use all or part of an Manufacturer's name in your query.
	    * 
	    * Manufacturer Option:
	    * An Manufacturer Name String
	    *
	    */
		$this->Manufacturer = $Manufacturer;
	}
	
	function getManufacturer()
	{
		return $this->Manufacturer;
	}
	
	function setMusicLabel($MusicLabel)
	{
	    /**
	    * Wed Sep 01 10:58:42 CDT 2004 10:58:42 - Ragsdale, Jason
	    *
	    * Use the MusicLabel parameter to refine your search by MusicLabel name. 
	    * You may use all or part of an MusicLabel's name in your query.
	    * 
	    * MusicLabel Option:
	    * An MusicLabel Name String
	    *
	    */
		$this->MusicLabel = $MusicLabel;
	}
	
	function getMusicLabel()
	{
		return $this->MusicLabel;
	}
	
	function setComposer($Composer)
	{
	    /**
	    * Wed Sep 01 10:58:37 CDT 2004 10:58:37 - Ragsdale, Jason
	    *
	    * Use the Composer parameter to refine your search by Composer name. 
	    * You may use all or part of an Composer's name in your query.
	    * 
	    * Composer Option:
	    * An Composer Name String
	    *
	    */
		$this->Composer = $Composer;
	}
	
	function getComposer()
	{
		return $this->Composer;
	}
	
	function setPublisher($Publisher)
	{
	    /**
	    * Wed Sep 01 10:58:25 CDT 2004 10:58:25 - Ragsdale, Jason
	    *
	    * Use the Publisher parameter to refine your search by Publisher name. 
	    * You may use all or part of an Publisher's name in your query.
	    * 
	    * Publisher Option:
	    * An Publisher Name String
	    *
	    */
		$this->Publisher = $Publisher;
	}
	
	function getPublisher()
	{
		return $this->Publisher;
	}
	
	function setBrand($Brand)
	{
	    /**
	    * Wed Sep 01 10:58:18 CDT 2004 10:58:18 - Ragsdale, Jason
	    *
	    * Use the Brand parameter to refine your search by Brand name. 
	    * You may use all or part of an Brand's name in your query.
	    * 
	    * Brand Option:
	    * An Brand Name String
	    *
	    */
		$this->Brand = $Brand;
	}
	
	function getBrand()
	{
		return $this->Brand;
	}
	
	function setConductor($Conductor)
	{
	    /**
	    * Wed Sep 01 10:57:35 CDT 2004 10:57:35 - Ragsdale, Jason
	    *
	    * Use the Conductor parameter to refine your search by Conductor name. 
	    * You may use all or part of an Conductor's name in your query.
	    * 
	    * Conductor Option:
	    * An Conductor Name String
	    *
	    */
		$this->Conductor = $Conductor;
	}
	
	function getConductor()
	{
		return $this->Conductor;
	}
	
	function setOrchestra($Orchestra)
	{
	    /**
	    * Wed Sep 01 10:56:59 CDT 2004 10:56:59 - Ragsdale, Jason
	    *
	    * Use the Orchestra parameter to refine your search by orchestra name. 
	    * You may use all or part of an orchestra's name in your query.
	    * 
	    * Orchestra Option:
	    * An Orchestra Name String
	    *
	    */
		$this->Orchestra = $Orchestra;
	}
	
	function getOrchestra()
	{
		return $this->Orchestra;
	}
	
	function setTextStream($TextStream)
	{
	    /**
	    * Wed Sep 01 10:55:36 CDT 2004 10:55:36 - Ragsdale, Jason
	    *
	    * Use the TextStream parameter to retrieve product search results based on a 
	    * block of text you specify in your request. The text block could be a search 
	    * term, a paragraph from a blog, an article excerpt, or any other text for which 
	    * you wish to retrieve product matches.
	    * 
        * When Amazon receives your request, Amazon parses out recognized keywords and 
        * returns an equal number of products (ten total) for each recognized keyword. 
        * For example, if you send a request with five recognized keywords, Amazon will 
        * return two products matching each recognized keyword.
        * 
        * Please note that the recognized keywords list Amazon uses for an ItemSearch using 
        * TextStream does not exclude conjunctions and helper words, such as "and", "or", 
        * "the", etc. Therefore, it would be a good idea to strip out these terms from the 
        * text you specify in your request so that Amazon does not return products matching 
        * them.
        * 
        * The TextStream parameter is only available for an ItemSearch using Amazon.com's catalog.
        * 
        * TextStream Options:
        * Any Block of Text
	    *
	    */
		$this->TextStream = $TextStream;
	}
	
	function getTextStream()
	{
		return $this->TextStream;
	}
	
	function setItemPage($ItemPage)
	{
	    /**
	    * Wed Sep 01 10:54:39 CDT 2004 10:54:39 - Ragsdale, Jason
	    *
	    * The ItemPage parameter allows you to create a paginated list of search results. 
	    * This parameter returns the specified page. When you use ItemPage, ItemSearch 
	    * will return 10 search results at a time. The maximum ItemPage number that can 
	    * be returned is 500. If you do not include ItemPage in your request, the first 
	    * page (containing the first 10 items, or all of the items if there are less than 
	    * 10) will be returned by default.
	    * 
	    * ItemPage Options:
	    * 1 (Default)
	    * Intergers 1 to 500
	    *
	    */
		$this->ItemPage = $ItemPage;
	}
	
	function getItemPage()
	{
		return $this->ItemPage;
	}
	
	function setSort($Sort)
	{
	    /**
	    * Wed Sep 01 10:53:03 CDT 2004 10:53:03 - Ragsdale, Jason
	    *
	    * Use the Sort parameter to specify how your item search results will be ordered. 
	    * Please note that valid sort values vary by search index and locale. The full 
	    * list of sort options are available in Sort Values.
	    * 
	    * Sort Options:
	    * See http://www.amazon.com/gp/aws/sdk/002-2261557-9296057
	    *
	    */
		$this->Sort = $Sort;
	}
	
	function getSort()
	{
		return $this->Sort;
	}
	
	function setCity($City)
	{
	    /**
	    * Wed Sep 01 10:52:10 CDT 2004 10:52:10 - Ragsdale, Jason
	    *
	    * Use the City parameter to refine your restaurant search by city name. You 
	    * may use all or part of a city's name in your query. At the present time, 
	    * AWS Product Data return restaurants for only select cities (see Valid Values). 
	    * This parameter may be used only when SearchIndex equals Restaurant and is only 
	    * applicable to US requests.
	    * 
	    * City Options:
	    * Boston
	    * Chicago
	    * New York
	    * San Francisco
	    * Seattle
	    * Washington, D.C.
	    *
	    */
		$this->City = $City;
	}
	
	function getCity()
	{
		return $this->City;
	}
	
	function setCuisine($Cuisine)
	{
	    /**
	    * Wed Sep 01 10:51:23 CDT 2004 10:51:23 - Ragsdale, Jason
	    *
	    * Use the Cuisine parameter to refine your restaurant search by cuisine name 
	    * (i.e., Chinese, Italian, American, etc.). You may use all or part of a cuisine's 
	    * name in your query. This parameter may be used only when SearchIndex equals 
	    * Restaurant and is only applicable to US requests.
	    * 
	    * Cuisine Options:
	    * A Cuisine Name String
	    *
	    */
		$this->Cuisine = $Cuisine;
	}
	
	function getCuisine()
	{
		return $this->Cuisine;
	}
	
	function setNeighborhood($Neighborhood)
	{
	    /**
	    * Wed Sep 01 10:50:40 CDT 2004 10:50:40 - Ragsdale, Jason
	    *
	    * Use the Neighborhood parameter to refine your restaurant search by neighborhood 
	    * name (i.e., Capitol Hill, Arlington, North Beach, etc.). You may use all or part 
	    * of a neighborhood's name in your query. This parameter may be used only when 
	    * SearchIndex equals Restaurant and is only applicable to US requests.
	    * 
	    * Neighborhood Options:
	    * A Neighborhood Name String
	    *
	    */
		$this->Neighborhood = $Neighborhood;
	}
	
	function getNeighborhood()
	{
		return $this->Neighborhood;
	}
	
	function setMinimumPrice($MinimumPrice)
	{
	    /**
	    * Wed Sep 01 10:50:03 CDT 2004 10:50:03 - Ragsdale, Jason
	    *
	    * Use the MinimumPrice parameter to set a lower price bound on products returned 
	    * by ItemSearch. The MinimumPrice value must be specified in pennies (or equivalent 
	    * in local currency).
	    * 
	    * MimimumPrice Options:
	    * An Interger
	    *
	    */
		$this->MinimumPrice = $MinimumPrice;
	}
	
	function getMinimumPrice()
	{
		return $this->MinimumPrice;
	}
	
	function setMaximumPrice($MaximumPrice)
	{
	    /**
	    * Wed Sep 01 10:49:23 CDT 2004 10:49:23 - Ragsdale, Jason
	    *
	    * Use the MaximumPrice parameter to set an upper price bound on products returned 
	    * by ItemSearch. The MaximumPrice value must be specified in pennies (or equivalent 
	    * in local currency).
	    * 
	    * MaximumPrice Options:
	    * An Interger
	    *
	    */
		$this->MaximumPrice = $MaximumPrice;
	}
	
	function getMaximumPrice()
	{
		return $this->MaximumPrice;
	}
	
	function setMerchantId($MerchantId)
	{
	    /**
	    * Wed Sep 01 10:48:04 CDT 2004 10:48:04 - Ragsdale, Jason
	    *
	    * Use the MerchantId parameter to filter the list of search results returned by 
	    * ItemSearch by the merchant offering the product.
	    * 
        * By setting MerchantId to "All" you may retrieve offers from Amazon partner 
        * merchants (such as Target, Toys"R"Us, Office Depot, and others) as well as 
        * independent marketplace sellers. You may also use the value "Featured," in 
        * which case AWS returns the same merchant that is displayed when you click 
        * the "Add to Shopping Cart" button on the product detail page. You may use a 
        * batch request to retrieve similarities filtered by MerchantId for up to two 
        * merchants.
        * 
        * MerchantId must be used to return variation data when the response groups 
        * VariationMinimum or VariationSummary are used, either together or separately.
        * 
        * The MerchantId parameter is available for Amazon.com requests only.
        * 
        * MerchantId Options:
        * All
        * Featured
        * A Merchant ID
	    *
	    */
		$this->MerchantId = $MerchantId;
	}
	
	function getMerchantId()
	{
		return $this->MerchantId;
	}
	
	function setCondition($Condition)
	{
	    /**
	    * Wed Sep 01 10:47:13 CDT 2004 10:47:13 - Ragsdale, Jason
	    *
	    * Use the Condition parameter to filter the offers returned in the product list by 
	    * condition type. By default, a request with the Condition parameter will return a 
	    * maximum of 10 offers, with a maximum of 5 offer listings per offer.
	    *
	    * Condition Options:
	    * New (Default)
	    * All
	    * Used
	    * Refurbished
	    * Collectible
	    */
		$this->Condition = $Condition;
	}
	
	function getCondition()
	{
		return $this->Condition;
	}
	
	function setDeliveryMethod($DeliveryMethod)
	{
	    /**
	    * Wed Sep 01 10:46:08 CDT 2004 10:46:08 - Ragsdale, Jason
	    *
	    * Use the DeliveryMethod parameter to filter offers returned in the product list 
	    * by delivery method. Valid values are Ship and ISPU (In-store pickup). If you use 
	    * ISPU, the offers returned will be ISPU offers from any postal code. To get ISPU 
	    * offers from a specific postal code, you must use the ItemLookup operation.
        * 
        * Available for Amazon.com only.
        * 
        * DeliveryMethod Options:
        * Ship (Default)
        * ISPU
	    *
	    */
		$this->DeliveryMethod = $DeliveryMethod;
	}
	
	function getDeliveryMethod()
	{
		return $this->DeliveryMethod;
	}
	
	function setAssociateTag($AssociateTag)
	{
	    /**
	    * Wed Sep 01 10:44:55 CDT 2004 10:44:55 - Ragsdale, Jason
	    *
	    * Use the AssociateTag parameter to specify your Amazon.com, Amazon.co.uk, Amazon.de, 
	    * or Amazon.co.jp Associate ID. The AssociateTag allows product URLs returned by AWS 
	    * to be tagged as originating from your Associates Web site. Be sure to specify the 
	    * tag value correctly, as no error is generated for incorrect tag values.
        * 
        * If you use those product URLs to link to Amazon, the Associate account connected to 
        * the Associate tag you specify will be credited for traffic and items sold through 
        * your links. Since you do not need to be an Associate to use AWS, AssociateTag is not 
        * a required parameter. If you do not include AssociateTag in your requests, a default 
        * Associate tag will be embedded in the product URLs in AWS responses.
        * 
        * AssociateTag Options:
        * An Amazon-assigned Associates tag
	    *
	    */
		$this->AssociateTag = $AssociateTag;
	}
	
	function getAssociateTag()
	{
		return $this->AssociateTag;
	}
	
	function setStyle($Style)
	{
	    /**
	    * Wed Sep 01 10:43:47 CDT 2004 10:43:47 - Ragsdale, Jason
	    *
	    * The Style parameter applies to REST requests only. Use the Style parameter to control 
	    * the format of the data returned by AWS in REST responses.
        * 
        * Set this parameter to "XML" to generate a pure XML response.
        * 
        * Set this parameter to the URL of an XSLT stylesheet to have AWS transform the XML response
        *  to another format you specify.
        * 
        * If you omit this parameter, AWS will return the pure XML response by default.
        * 
        * Style Options:
        * XML (Default)
        * A URL to a stylesheet
	    *
	    */
		$this->Style = $Style;
	}
	
	function getStyle()
	{
		return $this->Style;
	}
	
	function setContentType($ContentType)
	{
	    /**
	    * Wed Sep 01 10:42:24 CDT 2004 10:42:24 - Ragsdale, Jason
	    *
	    * The ContentType parameter is valid for REST requests only. The ContentType set in 
	    * your request is returned as the content type in the HTTP headers of the response 
	    * that AWS returns. Generally ContentType should only be changed when it is being used 
	    * in conjunction with an XSLT stylesheet specified with the Style parameter.
	    * 
	    * ContentType Options:
	    * text/xml
	    *
	    */
		$this->ContentType = $ContentType;
	}
	
	function getContentType()
	{
		return $this->ContentType;
	}
	
	function setInputContentEncoding($InputContentEncoding)
	{
	    /**
	    * Wed Sep 01 10:41:40 CDT 2004 10:41:40 - Ragsdale, Jason
	    *
	    * Use the InputContentEncoding parameter to notify AWS about how your request is encoded. 
	    * InputContentEncoding works for REST requests only.
        * 
        * InputContentEncoding Options:
        * Shift_JIS
        * UTF-8 (Default)
        * Latin-1
        * etc....
	    *
	    */
		$this->InputContentEncoding = $InputContentEncoding;
	}
	
	function getInputContentEncoding()
	{
		return $this->InputContentEncoding;
	}
	
	function setValidate($Validate)
	{
	    /**
	    * Wed Sep 01 10:40:06 CDT 2004 10:40:06 - Ragsdale, Jason
	    *
	    * Use the Validate parameter to have AWS test your request without actually executing it. 
	    * If this parameter is not specified, the default value is False (i.e., requests are 
	    * executed normally). When present, Validate must equal True. If the request is valid, 
	    * the response will contain an element called IsValid with a value of True. If the request 
	    * is invalid, the response will contain 1) an element called IsValid with a value of False 
	    * and 2) the errors that would be returned if the request were actually executed.
	    * 
	    * Notes:
        * Since the request is not actually executed, only a subset of the errors for the request 
        * may be returned. This is because some errors (i.e., no_exact_matches) are only generated 
        * during execution of a request.
        * 
        * The IsValid element will always be present in any response, regardless of whether the 
        * Validate parameter was in the request.
        * 
	    * Validate Options:
	    * True
	    */
		$this->Validate = $Validate;
	}
	
	function getValidate()
	{
		return $this->Validate;
	}
	
	function setVersion($Version)
	{
	    /**
	    * Wed Sep 01 10:36:57 CDT 2004 10:36:57 - Ragsdale, Jason
	    *
        * For REST requests, use the Version parameter to retrieve a particular version of the AWS 
        * WSDL. The value of the Version parameter is the date that is part of the WSDL's namespace.
        * For example, if the namespace is http://xml.amazon.com/AWSProductData/2004-03-19, then you
        * should set the Version parameter to 2004-03-19. Each time changes are made to AWS (for 
        * example, changed operation parameters, response groups, or behavior), a new WSDL is created
        *  with a new date.
        * 
        * For SOAP requests, this parameter is ignored because the version is retrieved from the WSDL namespace.
        * 
        * If the Version parameter is omitted in a REST request, AWS uses a default namespace. The 
        * default namespace may change as new versions of AWS are released. If you use XSLT to transform
        * AWS output, you should use the Version parameter to ensure that your stylesheets continue to 
        * work correctly when the default namespace is changed.
        *
	    * Version Options:
	    * A WSDL Namespace date
	    *
	    */
		$this->Version = $Version;
	}
	
	function getVersion()
	{
		return $this->Version;
	}
	
	function setXMLEscaping($XMLEscaping)
	{
	    /**
	    * Wed Sep 01 10:36:27 CDT 2004 10:36:27 - Ragsdale, Jason
	    *
        * Use the XMLEscaping parameter to specify whether responses are XML-encoded in a single
        * pass or a double pass. By default, XMLEscaping is Single, and AWS responses are encoded
        * only once in XML. For example, if the response data includes an ampersand character (&),
        * the character is returned in its regular XML encoding (&amp;). If XMLEscaping is Double,
        * the same ampersand character is XML-encoded twice (&amp;amp;).
        *
        * The Double value for XMLEscaping is useful in some clients, such as PHP, that do not decode
        * text within XML elements.
        *
	    * XMLEscaping Options:
	    * Single (Default)
	    * Double
	    *
	    */
		$this->XMLEscaping = $XMLEscaping;
	}
	
	function getXMLEscaping()
	{
		return $this->XMLEscaping;
	}
	
	
	/**
	* Wed Sep 01 09:51:11 CDT 2004 09:51:11 - Ragsdale, Jason
	*
	* The code below this comment is to be called after a XML page has been loaded.
	*
	*/
	function setResult($Result)
	{
		$this->Result = $Result;
	}
	
	function getResult()
	{
		return $this->Result;
	}
	
	/**
	* Wed Sep 01 09:51:34 CDT 2004 09:51:34 - Ragsdale, Jason
	*
	* checkXmlError will look at the xml result and see if Amazon returned a error. If
	* so then we will throw an exception
	*
	*/
	function checkXmlError()
	{
		if ($this->xml->Items->Request->IsValid == 'False') {
		    $error    = 'Error Code:'.$this->xml->Items->Request->Errors->Error->Code.'<p>';
		    $error   .= 'Message:'.$this->xml->Items->Request->Errors->Error->Message.'<p>';
            throw new Exception($error);
		}
	}
	
	/**
	* Wed Sep 01 09:52:10 CDT 2004 09:52:10 - Ragsdale, Jason
	*
	* return the total number of results/pages
	*
	*/
	function getTotalResults()
	{
		return $this->xml->Items->TotalResults;
	}
	
	function getTotalPages()
	{
		return $this->xml->Items->TotalPages;
	}
}

?>
:::::::::::::END aws4.inc.php::::::::::::::::
:::::::::::::BEGIN example.php:::::::::::::::
<?
/**
*
* example.php PHP code to lookup a list of movies from Amazon.com Version: 0.1
* by Jason Ragsdale (jrags (at) jasrags (dot) net)
* 
*   This program is free software; you can redistribute it and/or modify
*   it under the terms of the GNU General Public License as published by
*   the Free Software Foundation; either version 2 of the License, or
*   (at your option) any later version.
*
*   This program is distributed in the hope that it will be useful,
*   but WITHOUT ANY WARRANTY; without even the implied warranty of
*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*   GNU General Public License for more details.
*
*   You should have received a copy of the GNU General Public License
*   along with this program; if not, write to the Free Software
*   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*
*/

/**
* Thu Aug 26 15:45:47 CDT 2004 15:45:47 - jragsd00
*
* required files
*
*/
require_once('php/framework.inc.php');

/**
* Thu Sep 02 10:59:41 CDT 2004 10:59:41 - Ragsdale, Jason
*
* This code expects you send the following POST var's
* SearchIndex = any of the amazon.com search index options I.E. VHS, DVD
* title = keyword you wish to search for.
* The ResponseGroup is defaulted to Large in this example.
*
*/

//Start our class
$aws = new aws();

//Set our base URL based on our Country, Default = US
$aws->setBaseURL();

//Set our SearchIndex
$aws->setSearchIndex($_POST['SearchIndex']);

//Set our keywords
$aws->setKeywords(rtrim($_POST['title']));

//Set our ResponseGroup
$aws->setResponseGroup('Large');

//Fetch the page
$aws->fetch();

echo '<HTML><HEAD><TITLE>Search Results</TITLE></HEAD><BODY>';

echo 'Total Results: '.$aws->getTotalResults();
echo '<p>';
echo 'Total Pages: '.$aws->getTotalPages();
echo '<p>';
foreach ($aws->xml->Items->Item as $Item) {
    echo 'Name: '.$Item->ItemAttributes->Title.'<p>';
    echo 'ASIN: '.$Item->ASIN.'<p>';
    echo 'Theatrical Release Date: '.$Item->ItemAttributes->TheatricalReleaseDate.'<p>';
    echo 'Media Release Date: '.$Item->ItemAttributes->ReleaseDate.'<p>';
    echo 'Format: '.$Item->ItemAttributes->ProductGroup.'<p>';

}
?>
::::::::::::END example.php::::::::::::::::::::