amazOOP amazOOP
[ class tree: amazOOP ] [ index: amazOOP ] [ all elements ]

Class: AmazonQuery

Source Location: /aq.php

Class Overview

The AmazonQuery class is the software's main class.

Author(s):

Version: 0.3

Copyright: 2004 (c) Mauricio Diaz Orlich

Methods


Class Details [line 62]

The AmazonQuery class is the software's main class.

It is through this class that amazOOP connects to Amazon Web Services to obtain product information, make searches, etc. This class is also in charge of creating objects out of AWS responses and handles the cache.

An AmazonQuery object can be used for lite searches, using liteQuery(), heavy searches, using heavyQuery(), or queries to a Remote Shopping Cart, using one of the functions for this purpose (newCart(), addToCart(), modifyCart, removeFromCart(), clearCart() and getCart()).




Tags:

Version:  0.3
  
License:  GNU General Public License
  
Copyright:  2004 (c) Mauricio Diaz Orlich
  
Author:  Mauricio Diaz <madd0@users.sourceforge.net>


[ Top ]


Class Methods


constructor AmazonQuery [line 75]

AmazonQuery AmazonQuery( )

Creates a new object ready to query AWS.

An AmazonQuery object can be used for lite searches, using liteQuery(), heavy searches, using heavyQuery(), or queries to a Remote Shopping Cart, using one of the functions for this purpose (newCart(), addToCart(), modifyCart, removeFromCart(), clearCart() and getCart()).




[ Top ]

method addToCart [line 1122]

ShoppingCart addToCart( array $items, [string $locale = "us"], [string $cartID = ""], [string $HMAC = ""], [boolean $similar = true])

Add an item, or a list of items to an existing manual.cart.pkg.

This function is used to add items to an existing Remote Shopping Cart. To create a new shopping cart take a look at newCart().

If you do not provide the $cartID and $HMAC parameters, or if these are equal to a blank string, this function behaves exactly like newCart().

Example:

  1. $items = array();
  2. $items[] = array("B00005JMEW", 1);
  3. $items[] = array("1932273271", 2);
  4.  
  5. $cart = $aq->addToCart($items, "us", $_SESSION['cartID'], $_SESSION['HMAC']);




Tags:

Return:  A shopping cart containing the items added, plus any other items already in it.


Parameters:

array   $items   Each element of this array is another array containing the ASIN of the product you wish to add to the cart in position 0, and the quantity in position 1. As of the writing of this document, only US shopping carts support multiple items.
string   $locale   The locale where the Remote Shopping Cart is stored. Valid values are:
  • "us"
  • "uk"
  • "de"
  • "jp"
string   $cartID   The unique ID of the cart you whish to add items to. You can find the cart ID of a ShoppingCart object using its getCartID() method.
string   $HMAC   A unique code associated to a Remote Shopping Cart.You can find the HMAC of a ShoppingCart object using its getHMAC() method.
boolean   $similar   If set to "true", the ShoppingCart object returned will contain a list of ASINs related to the contents of the cart.

[ Top ]

method clearCart [line 1268]

ShoppingCart clearCart( string $cartID, string $HMAC, [string $locale = "us"], [boolean $similar = true])

Clears a Remote Shopping Cart.



Tags:

Return:  An empty shopping cart.


Parameters:

string   $cartID   The unique identifier of the cart you want to clear.
string   $HMAC   A unique code associated to the cart ID.
string   $locale   The locale where the Remote Shopping Cart is stored. Valid values are:
  • "us"
  • "uk"
  • "de"
  • "jp"
boolean   $similar   If set to "true", the ShoppingCart object returned will contain a list of ASINs related to the contents of the cart.

[ Top ]

method getBrowseNode [line 165]

ProductInfo getBrowseNode( integer $bn, string $mode, [string $locale = "us"], [string $type = "lite"], [integer $page = 1], [string $sort = "Bestselling"])

Queries an AWS Browse Node, that has not been specified as an amazOOP category for all its products.



Tags:

Return:  a ProductInfo object containing zero or more results returned by AWS.
  
Tutorial:  Other Search Types
Tutorial:  Sorting Results
Tutorial:  amazOOP Categories
Tutorial:  About Browse Nodes
  
See:  ProductInfo


Parameters:

integer   $bn   the browse node you want to search. Read the tutorial on Browse Nodes to learn all about AWS browse nodes.
string   $mode   when requesting products from a browse node, you have to specify a "mode". You should read the tutorial on Browse Nodes to learn more about modes.
string   $locale   determines what Amazon site should be queried. Valid locales are:
  • "us": queries the Amazon.com catalog
  • "uk": queries the Amazon.co.uk catalog
  • "jp": queries the Amazon.co.jp catalog
  • "de": queries the Amazon.de catalog
string   $type   "lite" or "heavy", determines how much information you want from AWS. For more information on what type of information each type of request returns, take a look at LiteDetails and HeavyDetails.
integer   $page   indicates the page of results you want. Each page contains 10 results.
string   $sort   indicates what parameter determines the sorting of results. Available sort types are described in document Sorting Results.

[ Top ]

method getCart [line 1245]

ShoppingCart getCart( string $cartID, string $HMAC, [string $locale = "us"], [boolean $similar = true])

Retrieve the contents of an existing manual.cart.pkg.

This function is used to retrieve an existing Remote Shopping Cart. Note that every other action (new, add, modify, remove and clear) will also return the contents from the cart, therefore you only need to use this function if you want to retrieve a cart without mofifying it.

Example:

  1. $cart = $aq->getCart($_COOKIE['cartID'], $_COOKIE['HMAC'], "de");




Tags:

Return:  A the contents of the requested shopping cart.


Parameters:

string   $cartID   The unique ID of the cart you whish to add items to. You can find the cart ID of a ShoppingCart object using its getCartID() method.
string   $HMAC   A unique code associated to a Remote Shopping Cart.You can find the HMAC of a ShoppingCart object using its getHMAC() method.
string   $locale   The locale where the Remote Shopping Cart is stored. Valid values are:
  • "us"
  • "uk"
  • "de"
  • "jp"
boolean   $similar   If set to "true", the ShoppingCart object returned will contain a list of ASINs related to the contents of the cart.

[ Top ]

method getCategory [line 121]

ProductInfo getCategory( [string $category = "books"], [string $locale = "us"], [string $type = "lite"], [integer $page = 1], [string $sort = "Bestselling"])

Queries an amazOOP category for all its products.

Example:

  1. $books = $aq->getCategory("books", "uk");
  2.  
  3. for($i = 1; $book = $books->getDetails($i); $i++){
  4. echo $book->getProductName() . "<br>";
  5.  
  6. echo $book->getAuthors(2) . "<br>";
  7. }




Tags:

Return:  a ProductInfo object containing zero or more results returned by AWS.
  
Tutorial:  Other Search Types
Tutorial:  Sorting Results
Tutorial:  amazOOP Categories
  
See:  ProductInfo


Parameters:

string   $category   the category you want to search. Read advanced.categories.pkg to learn all about amazOOP categories and how to customize them.
string   $locale   determines what Amazon site should be queried. Valid values are:
  • "us": queries the Amazon.com catalog
  • "uk": queries the Amazon.co.uk catalog
  • "jp": queries the Amazon.co.jp catalog
  • "de": queries the Amazon.de catalog
string   $type   "lite" or "heavy", determines how much information you want from AWS. For more information on what type of information each type of request returns, take a look at LiteDetails and HeavyDetails.
integer   $page   indicates the page of results you want. Each page contains 10 results.
string   $sort   indicates what parameter determines the sorting of results. Available sort types are described in document Sorting Results.

[ Top ]

method heavyQuery [line 469]

mixed heavyQuery( string $keywords, string $searchType, [string $mode = "books"], [string $locale = "us"], [integer $page = 1], [string $sort = "Bestselling"])

Makes a "heavy" request to AWS.

Products obtained from a heavy request are stored in objects of type HeavyDetails, and can contain all the attributes defined in this kind of objects, athough this is not necessarily the case.

Although this function can return ProductInfo or BlendedSearch objects based on the kind of search you are doing, these objects will only contain HeavyDetails objects, and in no case LiteDetails objects.




Tags:

Return:  

This function can return one of the following two types, depending on the query made:

  • ProductInfo: this is returned by most types of queries. This object contains zero
or more HeavyDetails objects. For more information on what types of queries return ProductInfo objects, read the tutorial Other Search Types.

object contains zero or more ProductInfo objects. For more information about Blended searches read the tutorial Other Search Types.

  
Tutorial:  Sorting Results
Tutorial:  About Browse Nodes
Tutorial:  amazOOP Categories
Tutorial:  Other Search Types
Tutorial:  Making a "heavy" request, an example of an ASIN search
  
See:  BlendedSearch
See:  ShoppingCart
See:  ProductInfo


Parameters:

string   $keywords   the use of this paramater may vary depending of the type of search you are making: for a BrowseNode search, it would refer to the desired BrowseNode, in the case of an ASIN serach, it would refer to the desired ASIN, and so on...
string   $searchType   one of the search types offered by AWS. Refer to the document Other Search Types for a list of valid search types.
string   $mode   an amazOOP category. To learn more about amazOOP categories read the tutorial amazOOP Categories.
string   $locale   determines what Amazon site should be queried. Valid locales are:
  • "us": queries the Amazon.com catalog
  • "uk": queries the Amazon.co.uk catalog
  • "jp": queries the Amazon.co.jp catalog
  • "de": queries the Amazon.de catalog
integer   $page   indicates the page of results you want. Each page contains 10 results.
string   $sort   indicates what parameter determines the sorting of results. Available sort types are described in document Sorting Results.

[ Top ]

method liteQuery [line 413]

mixed liteQuery( string $keywords, string $searchType, [string $mode = "books"], [string $locale = "us"], [integer $page = 1], [string $sort = "Bestselling"])

Makes a "lite" request to AWS.

Products obtained from a lite request are stored in objects of type LiteDetails, and can contain all the attributes defined in this kind of objects, athough this is not necessarily the case.

Although this function can return ProductInfo or BlendedSearch objects based on the kind of search you are doing, these objects will only contain LiteDetails objects, and in no case HeavyDetails objects.




Tags:

Return:  

This function can return one of the following two types, depending on the query made:

  • ProductInfo: this is returned by most types of queries. This object contains zero
or more LiteDetails objects. For more information on what types of queries return ProductInfo objects, read the tutorial Other Search Types.

object contains zero or more ProductInfo objects. For more information about Blended searches read the tutorial Other Search Types.

  
Tutorial:  Sorting Results
Tutorial:  About Browse Nodes
Tutorial:  amazOOP Categories
Tutorial:  Other Search Types
Tutorial:  Making a "lite" request, an example of an ISBN search
  
See:  BlendedSearch
See:  ShoppingCart
See:  ProductInfo


Parameters:

string   $keywords   the use of this paramater may vary depending of the type of search you are making: for a BrowseNode search, it would refer to the desired BrowseNode, in the case of an ASIN serach, it would refer to the desired ASIN, and so on...
string   $searchType   one of the search types offered by AWS. Refer to the document Other Search Types for a list of valid search types.
string   $mode   an amazOOP category. To learn more about amazOOP categories read the tutorial amazOOP Categories.
string   $locale   determines what Amazon site should be queried. Valid locales are:
  • "us": queries the Amazon.com catalog
  • "uk": queries the Amazon.co.uk catalog
  • "jp": queries the Amazon.co.jp catalog
  • "de": queries the Amazon.de catalog
integer   $page   indicates the page of results you want. Each page contains 10 results.
string   $sort   indicates what parameter determines the sorting of results. Available sort types are described in document Sorting Results.

[ Top ]

method modifyCart [line 1169]

ShoppingCart modifyCart( array $items, [string $locale = "us"], [string $cartID = ""], [string $HMAC = ""], [boolean $similar = true])

Modifies the quantities of items in an existing manual.cart.pkg.

This function is used to modify the quantities of items you have already added to a Remote Shopping Cart. To create a add new items to a cart take a look at addToCart().

You must provide an array of items to be modified. This array must contain Item IDs of products already in the shopping cart, associated with their new quantities.

Example:

  1. $noOfModItems = $_POST['noOfItems'];
  2. $items = array();
  3.  
  4. for($i = 0; $i < $noOfModItems; $i++)
  5. $items[] = array($_POST['itemID'.$i], $_POST['qty'.$i]);
  6.  
  7. $cart = $aq->modifyCart($items, "us", $_POST['cartID'], $_POST['HMAC']);




Tags:

Return:  A shopping cart containing the modified items, plus any other items already in it.


Parameters:

array   $items   Each element of this array is another array containing the Item ID of a product in the cart in position 0, and the new quantity in position 1. As of the writing of this document, only US shopping carts support multiple items.
string   $locale   The locale where the Remote Shopping Cart is stored. Valid values are:
  • "us"
  • "uk"
  • "de"
  • "jp"
string   $cartID   The unique ID of the cart you whish to add items to. You can find the cart ID of a ShoppingCart object using its getCartID() method.
string   $HMAC   A unique code associated to a Remote Shopping Cart.You can find the HMAC of a ShoppingCart object using its getHMAC() method.
boolean   $similar   If set to "true", the ShoppingCart object returned will contain a list of ASINs related to the contents of the cart.

[ Top ]

method newCart [line 1077]

ShoppingCart newCart( array $items, [string $locale = "us"], [boolean $similar = true])

Add an item, or a list of items to an new manual.cart.pkg.

This function is used to add items to an new Remote Shopping Cart. To add items to an existing shopping cart take a look at addToCart().

You must recover the new cart's ID and HMAC by using methods getCartID() and getHMAC(), in order to modify it using functions addToCart(), modifyCart, removeFromCart(), clearCart() and getCart().

Example:

  1. $items = array();
  2. $items[] = array("B00005JMEW", 1);
  3. $items[] = array("1932273271", 2);
  4.  
  5. $cart = $aq->newCart($items, "jp");




Tags:

Return:  A new shopping cart containing the items added.


Parameters:

array   $items   Each element of this array is another array containing the ASIN of the product you wish to add to the cart in position 0, and the quantity in position 1. As of the writing of this document, only US shopping carts support multiple items.
string   $locale   The locale where the Remote Shopping Cart is stored. Valid values are:
  • "us"
  • "uk"
  • "de"
  • "jp"
boolean   $similar   If set to "true", the ShoppingCart object returned will contain a list of ASINs related to the contents of the cart.

[ Top ]

method query [line 222]

mixed query( string $keywords, string $searchType, [string $mode = "books"], [string $locale = "us"], [string $type = "lite"], [integer $page = 1], [string $sort = "Bestselling"])

Queries AWS as instructed.

This is the "low-level" method used to query AWS. Methods such as getCategory(), getBrowseNode(), liteQuery(), or heavyQuery(), all call this method. As a matter of fact, you should rather use one of the aforementioned methods unless you feel quite confortable with amazOOP.




Tags:

Return:  This function can return one of the following three types, depending on the query made:
  • ProductInfo: this is returned by most types of queries. This object contains zero
or more LiteDetails or HeavyDetails objects, depending on the $type requested. For more information on what types of queries return ProductInfo objects, read the tutorial Other Search Types. object contains zero or more ProductInfo objects. For more information about Blended searches read the tutorial Other Search Types.
  
Tutorial:  About Browse Nodes
Tutorial:  amazOOP Categories
Tutorial:  Sorting Results
Tutorial:  Other Search Types
  
See:  BlendedSearch
See:  ShoppingCart
See:  ProductInfo


Parameters:

string   $keywords   the use of this paramater may vary depending of the type of search you are making: for a BrowseNode search, it would refer to the desired BrowseNode, in the case of an ASIN serach, it would refer to the desired ASIN, and so on...
string   $searchType   one of the search types offered by AWS. Refer to the document Other Search Types for a list of valid search types.
string   $mode   one of the modes proposed by AWS. Read the document About Browse Nodes for an explanation of modes.
string   $locale   determines what Amazon site should be queried. Valid locales are:
  • "us": queries the Amazon.com catalog
  • "uk": queries the Amazon.co.uk catalog
  • "jp": queries the Amazon.co.jp catalog
  • "de": queries the Amazon.de catalog
string   $type   "lite" or "heavy", determines how much information you want from AWS.
integer   $page   indicates the page of results you want. Each page contains 10 results.
string   $sort   indicates what parameter determines the sorting of results. Available sort types are described in document Sorting Results.

[ Top ]

method queryRemoteShoppingCart [line 952]

ShoppingCart queryRemoteShoppingCart( [string $action = "get"], [array $items = ""], [string $locale = "us"], [string $cartID = ""], [string $HMAC = ""], [boolean $similar = true])

A variant of query() used specifically to query a Remote Shopping Cart.

Like query(), this is a "low-level" function, therefore most users will prefer to use the Remote Shopping Cart with newCart(), addToCart(), modifyCart, removeFromCart(), clearCart() and getCart().




Tags:

Return:  Unlike query(), this function only returns objects of type ShoppingCart. Read the tutorial Using the Remote Shopping Cart for more information about Remote Shoppng Carts.
  
Tutorial:  Using the Remote Shopping Cart
  
See:  ShoppingCart


Parameters:

string   $action   The action you want to perform with a Shopping Cart. Valid values are:
  • "add": adds items to a shopping cart, or creates a new shopping cart if none is provided
  • "modify": modifies the quantity of an item in the shopping cart
  • "remove": removes an item from the shopping cart
  • "clear": clears a shopping cart
  • "get": retrieves the items from a shopping cart
array   $items   This can be a simple or a bi-dimensional array. It is simple if you want to remove items from a shopping cart, in which case this is simply an array of Item IDs. But it is a bi-dimensional array if you want to add or modify items in a shopping cart. In this case each item of the array is another array containing an ASIN (if you are adding a product), or an Item ID (if you are modifying the cart), and the desired quantity of this product.
string   $locale   The Amazon site in which the cart is stored.
string   $cartID   The Cart ID is the unique identifier for a given shopping cart.
string   $HMAC   The HMAC is a security token that must be passed back to Amazon Web Services for using an existing cart. This token is uniquely associated with each cart.
boolean   $similar   If this parameter is set to "true" (default) the Shopping Cart will contain a list of ASINs related to the objects it contains.

[ Top ]

method removeFromCart [line 1210]

ShoppingCart removeFromCart( array $items, [string $locale = "us"], [string $cartID = ""], [string $HMAC = ""], [boolean $similar = true])

Removes items from an existing manual.cart.pkg.

You must provide an array of items to be removed. This array must contain Item IDs of the products you wish to remove from the shopping cart.

Example:

  1. $items = array();
  2.  
  3. for($i = 0; $i < $_POST['noOfItems']; $i++)
  4. $items[] = $_POST['itemID'.$i];
  5.  
  6. $cart = $aq->removeFromCart($items, "us", $_POST['cartID'], $_POST['HMAC']);




Tags:

Return:  A shopping cart without the removed items.


Parameters:

array   $items   Each element of this array is an Item ID of a product in the cart.
string   $locale   The locale where the Remote Shopping Cart is stored. Valid values are:
  • "us"
  • "uk"
  • "de"
  • "jp"
string   $cartID   The unique ID of the cart you whish to add items to. You can find the cart ID of a ShoppingCart object using its getCartID() method.
string   $HMAC   A unique code associated to a Remote Shopping Cart.You can find the HMAC of a ShoppingCart object using its getHMAC() method.
boolean   $similar   If set to "true", the ShoppingCart object returned will contain a list of ASINs related to the contents of the cart.

[ Top ]

method rssFeed [line 497]

string rssFeed( string $browseNode, [string $mode = "books"], [string $locale = "us"], [mixed $page = 1])

Generates an RSS 2.0 feed for a Browse Node from Amazon.

You should read the tutorial

WARNING!!! This is an experimental feature. Use it, tweak it, and send feedback!!!




Tags:

Return:  The XML document containing the RSS feed.
  
Modified:  2004-05-21 10:04
  
Link:  RSS 2.0
Link:  AWS SDK


Parameters:

string   $browseNode   a browse node from Amazon. Not all Amazon browse nodes will return information. Take a look at this document for more info
string   $mode   one of the modes proposed by AWS. The names were simplified, an array in config.inc.php holds the associations.
string   $locale   determines what Amazon site should be queried. config.inc.php contains an array of available locales.

[ Top ]

 
Documentation generated on Sat, 21 Aug 2004 17:40:20 +0200 by phpDocumentor 1.3.0RC3
hosted by
SourceForge.net Logo