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

Class: Services_Amazon

Source Location: /Services_Amazon-0.7.1/Amazon.php

Class Overview


Class for accessing and retrieving information from Amazon's Web Services.


Author(s):

Version:

  • Release: 0.7.1

Methods


Inherited Variables

Inherited Methods


Class Details

[line 76]
Class for accessing and retrieving information from Amazon's Web Services.
  • Author: John Downey <jdowney@gmail.com>
  • Author: Tatsuya Tsuruoka <ttsuruoka@p4life.jp>
  • Version: Release: 0.7.1
  • Access: public
  • Uses: XML_Unserializer
  • Uses: HTTP_Request
  • Uses: PEAR


[ Top ]


Method Detail

Services_Amazon (Constructor)   [line 121]

Services_Amazon Services_Amazon( [string $token = null], [string $affid = null], [ $locale = 'us'], [ $baseurl = 'http://webservices.amazon.com/onca/xml2'])

Constructor

Parameters:

string   $token   —  The developers token used when quering Amazon servers.
string   $affid   —  An Amazon Associate ID used in the URL's so a commision may be payed.
   $locale   — 
   $baseurl   — 

[ Top ]

getApiVersion   [line 146]

string getApiVersion( )

Retrieves the current version of this classes API.

All major versions are backwards compatible with older version of the same version number. Such as 1.5 would work for a script written to use 1.0. However on the filp side a script that needs 1.5 would not work with API version 1.0.

  • Return: the API version
  • Access: public

[ Top ]

getAssociateID   [line 188]

string getAssociateID( )

Retrieves the currently set Associate ID.

Your Associate ID is used to built the links to amazon which will give you credit for the sale. Visit http://associates.amazon.com to sign up for an Associate ID.


[ Top ]

getBaseUrl   [line 211]

string getBaseUrl( )

Retrieves the currently set base url.

[ Top ]

getLocale   [line 234]

string getLocale( )

Retrieves the locale passed when making a query to Amazon.com.

[ Top ]

getModes   [line 294]

array getModes( )

Retrieves an array of modes supported by Amazon.

The array is arranged with the shorthand version as the key and the human readable version as its value. Below are the current modes in the list.

 baby        - Baby
 books       - Books
 classical   - Classical Music
 dvd         - DVD
 electronics - Electronics
 garden      - Outdoor Living
 kitchen     - Kitchen & Housewares
 magazines   - Magazines
 music       - Popular Music
 pc-hardware - Computers
 photo       - Camera & Photo
 software    - Software
 toys        - Toys & Games
 universal   - Tools & Hardware
 vhs         - VHS
 videogames  - Computer & Video Games

  • Return: An array of modes with the short hand modename to pass to Amazon as the key and the longer human readable form as the key's value.
  • Access: public

[ Top ]

getToken   [line 161]

string getToken( )

Retrieves the currently set Developer token.

To use Amazon's Web Services you need a developer's token. Visit http://www.amazon.com/webservices and read their license agreement to recieve a free token.


[ Top ]

searchActor   [line 562]

array searchActor( string $actor, [string $mode = 'dvd'], [interger $page = 1])

Searches Amazon for movies that portrays a specific actor.

Example:

  1.  <?php
  2.  require_once 'PEAR.php';
  3.  require_once 'Services/Amazon.php';
  4.  
  5.  $amazon &new Services_Amazon('XXXXXXXXXXXXXX''myassociateid');
  6.  $products $amazon->searchActor('Samuel L. Jackson');
  7.  
  8.  if(!PEAR::isError($products)) {
  9.     var_dump($products);
  10.  else {
  11.     echo $products->message;
  12.  }
  13.  ?>
If you were to fill in the Developer token in the constructor this would search Amazon.com for DVD movies portraying the American Actor Samuel L. Jackson.


Parameters:

string   $actor   —  The actor you are searching for.
string   $mode   —  The section of the site you wish to search in. Defaults to DVDs.
interger   $page   —  Which page of products to retrieve. Defaults to the first.

[ Top ]

searchArtist   [line 526]

array searchArtist( string $artist, [interger $page = 1])

Searches Amazon for music by a specified artist.

Example:

  1.  <?php
  2.  require_once 'PEAR.php';
  3.  require_once 'Services/Amazon.php';
  4.  
  5.  $amazon &new Services_Amazon('XXXXXXXXXXXXXX''myassociateid');
  6.  $products $amazon->searchArtist('Dream Theater');
  7.  
  8.  if(!PEAR::isError($products)) {
  9.     var_dump($products);
  10.  else {
  11.     echo $products->message;
  12.  }
  13.  ?>
If you were to fill in the Developer token in the constructor this would search Amazon.com for music by American Progressive Metal band Dream Theater.

  • Return: The array of products retrieved by the query.
  • Access: public

Parameters:

string   $artist   —  The artist you are searching for.
interger   $page   —  Which page of products to retrieve. Defaults to the first.

[ Top ]

searchAsin   [line 345]

array searchAsin( string $asin)

Retrives the information of a product given its unique ASIN code.

Amazon Standard Identification Numbers (ASINs) are unique blocks of 10 letters and/or numbers that identify items. You can find the ASIN on the item's product information page at Amazon.com.

Example:

  1.  <?php
  2.  require_once 'PEAR.php';
  3.  require_once 'Services/Amazon.php';
  4.  
  5.  $amazon &new Services_Amazon('XXXXXXXXXXXXXX''myassociateid');
  6.  $products $amazon->searchAsin('0672325616');
  7.  
  8.  if(!PEAR::isError($products)) {
  9.      var_dump($products);
  10.  else {
  11.      echo $products->message;
  12.  }
  13.  ?>
If you were to fill in the Developer token in the constructor this would return the results for George Schlossnagle's book Advanced PHP Programming.

  • Return: The array of products retrieved by the query.
  • Access: public

Parameters:

string   $asin   —  The Amazon Standard Identification Number (ASIN) of the product your searching for

[ Top ]

searchAuthor   [line 493]

array searchAuthor( string $author, [interger $page = 1])

Searches Amazon.com for a specific author.

Example:

  1.  <?php
  2.  require_once 'PEAR.php';
  3.  require_once 'Services/Amazon.php';
  4.  
  5.  $amazon &new Services_Amazon('XXXXXXXXXXXXXX''myassociateid');
  6.  $products $amazon->searchAuthor('Frank Herbert');
  7.  
  8.  if(!PEAR::isError($products)) {
  9.     var_dump($products);
  10.  else {
  11.     echo $products->message;
  12.  }
  13.  ?>
If you were to fill in the Developer token in the constructor this would search Amazon.com for all books written by the great American author Frank Herbert.

  • Return: The array of products retrieved by the query.
  • Access: public

Parameters:

string   $author   —  The author you are searching for.
interger   $page   —  Which page of products to retrieve. Defaults to the first.

[ Top ]

searchDirector   [line 597]

array searchDirector( string $director, [string $mode = 'dvd'], [interger $page = 1])

Searches Amazon for movies by their given director.

Example:

  1.  <?php
  2.  require_once 'PEAR.php';
  3.  require_once 'Services/Amazon.php';
  4.  
  5.  $amazon &new Services_Amazon('XXXXXXXXXXXXXX''myassociateid');
  6.  $products $amazon->searchDirector('George Lucas');
  7.  
  8.  if(!PEAR::isError($products)) {
  9.     var_dump($products);
  10.  else {
  11.     echo $products->message;
  12.  }
  13.  ?>
If you were to fill in the Developer token in the constructor this would search Amazon.com for DVD movies directed by American film Director George Lucas.


Parameters:

string   $director   —  The director you are searching for.
string   $mode   —  The section of the site you wish to search in
interger   $page   —  Which page of products to retrieve. Defaults to the first.

[ Top ]

searchIsbn   [line 363]

array searchIsbn( string $isbn)

Retrives the information of a book given its unique ISBN number.

International Standard Book Numbers (ISBNs) are unique numbers that identify every book that is published. It is generally located below a barcode on the back of the book. Note: ISBN numbers are synonymous with ASIN numbers as Amazon uses the ISBN for a books ASIN.


Parameters:

string   $isbn   —  The International Standard Book Number (ISBN) of the book you are searching for.

[ Top ]

searchKeyword   [line 419]

array searchKeyword( string $keyword, [string $mode = null], [interger $page = 1])

Searches Amazon.com for a specific keyword.

To limit your search to just a specific category such as books then set the $mode param to something other then null. See getModes() for a list of modes.

Example:

  1.  <?php
  2.  require_once 'PEAR.php';
  3.  require_once 'Services/Amazon.php';
  4.  
  5.  $amazon &new Services_Amazon('XXXXXXXXXXXXXX''myassociateid');
  6.  $products $amazon->searchKeyword('PHP');
  7.  
  8.  if(!PEAR::isError($products)) {
  9.     var_dump($products);
  10.  else {
  11.     echo $products->message;
  12.  }
  13.  ?>
If you were to fill in the Developer token in the constructor this would search Amazon.com for all books about PHP and return the first 10 results. To retrieve more results you would pass a page number.


Parameters:

string   $keyword   —  The keyword to search for.
string   $mode   —  The section of the site you wish to search in. Defaults to music.
interger   $page   —  Which page of products to retrieve. Defaults to the first.

[ Top ]

searchManufacturer   [line 634]

array searchManufacturer( string $manufacturer, [string $mode = 'books'], [interger $page = 1])

Search Amazon for products from a specific manufacturer.

This search is synonymous with searching for a book publisher.

Example:

  1.  <?php
  2.  require_once 'PEAR.php';
  3.  require_once 'Services/Amazon.php';
  4.  
  5.  $amazon &new Services_Amazon('XXXXXXXXXXXXXX''myassociateid');
  6.  $products $amazon->searchManufacturer('New Line''dvd');
  7.  
  8.  if(!PEAR::isError($products)) {
  9.     var_dump($products);
  10.  else {
  11.     echo $products->message;
  12.  }
  13.  ?>
If you were to fill in the Developer token in the constructor this would search Amazon.com for DVD movies put out by American film company New Line Cinemas.


Parameters:

string   $manufacturer   —  The manufacturer you are searching for.
string   $mode   —  The section of the site you wish to search in.
interger   $page   —  Which page of products to retrieve. Defaults to the first.

[ Top ]

searchPublisher   [line 670]

array searchPublisher( $publisher, [interger $page = 1], string $manufacturer, string $mode)

Search Amazon for products from a specific book publisher.

Example:

  1.  <?php
  2.  require_once 'PEAR.php';
  3.  require_once 'Services/Amazon.php';
  4.  
  5.  $amazon &new Services_Amazon('XXXXXXXXXXXXXX''myassociateid');
  6.  $products $amazon->searchPublisher('Coriolis''books');
  7.  
  8.  if(!PEAR::isError($products)) {
  9.     var_dump($products);
  10.  else {
  11.     echo $products->message;
  12.  }
  13.  ?>
If you were to fill in the Developer token in the constructor this would search Amazon.com for books published by Coriolis Group Books which publish the "Black Book" series of programming books, some of my favorites.

  • Return: The array of products retrieved by the query.
  • Access: public

Parameters:

string   $manufacturer   —  The manufacturer or book publisher you are searching for.
string   $mode   —  The section of the site you wish to search in.
interger   $page   —  Which page of products to retrieve. Defaults to the first.
   $publisher   — 

[ Top ]

searchSimilar   [line 460]

array searchSimilar( string $asin, [string $mode = null], [interger $page = 1])

Searches Amazon for products similer to the Asin passed to it.

To limit your search to just a specific category such as books then set the $mode param to something other then null. See getModes() for a list of modes. If the $mode param is null it will search all modes.

Example:

  1.  <?php
  2.  require_once 'PEAR.php';
  3.  require_once 'Services/Amazon.php';
  4.  
  5.  $amazon &new Services_Amazon('XXXXXXXXXXXXXX''myassociateid');
  6.  $products $amazon->searchSimilar('0672325616''books');
  7.  
  8.  if(!PEAR::isError($products)) {
  9.     var_dump($products);
  10.  else {
  11.     echo $products->message;
  12.  }
  13.  ?>
If you were to fill in the Developer token in the constructor this would search Amazon.com for all books related to George Schlossnagle's book Advanced PHP Programming. To retrieve more results you would pass a page number.


Parameters:

string   $asin   —  The Asin of the product that is similer to what you are searching for.
string   $mode   —  The section of the site you wish to search in
interger   $page   —  Which page of products to retrieve. Defaults to the first.

[ Top ]

searchUpc   [line 379]

array searchUpc( string $upc)

Retrives the information of a product given its unique UPC number.

Since Amazon usually carries the latest version of a product it may not be possible to find a product given its UPC even though a later version appears on Amazon.com.

  • Return: The array of products retrieved by the query.
  • Access: public

Parameters:

string   $upc   —  Universal Product Code (UPC) for the product you are searching for.

[ Top ]

searchWishlist   [line 707]

array searchWishlist( string $wishlist)

Retrieves a persons wishlist items given their unique ID.

To find a specific wish list ID number, simply travel to the page that contains the list that you are interested in, and look for the list's 13 character ID in web page's URL. (It appears after the "/obidos/registry/" string). As an example, the following URL contains the list ID 1QKCTUTWKI1AZ: http://www.amazon.com/exec/obidos/registry/1QKCTUTWKI1AZ.

Example:

  1.  <?php
  2.  require_once 'PEAR.php';
  3.  require_once 'Services/Amazon.php';
  4.  
  5.  $amazon &new Services_Amazon('XXXXXXXXXXXXXX''myassociateid');
  6.  $products $amazon->searchWishlist('1QKCTUTWKI1AZ');
  7.  
  8.  if(!PEAR::isError($products)) {
  9.     var_dump($products);
  10.  else {
  11.     echo $products->message;
  12.  }
  13.  ?>
If you were to fill in the Developer token in the constructor this would search Amazon.com for my wishlist and return all the products currently on it.

  • Return: The array of products retrieved by the query.
  • Access: public

Parameters:

string   $wishlist   —  The ID of the wishlist you wish to retrieve.

[ Top ]

setAssociateID   [line 200]

void setAssociateID( string $affid)

Sets the Associate ID to use when building links to Amazon.com.

Parameters:

string   $affid   —  your Associate ID

[ Top ]

setBaseUrl   [line 223]

void setBaseUrl( string $baseurl)

Sets the base url used when making a query to Amazon.com.

Parameters:

string   $baseurl   —  the base url to use

[ Top ]

setLocale   [line 248]

void setLocale( string $locale)

Sets the locale passed when making a query to Amazon.

Currently only us, uk, de, jp, fr and ca are supported by Amazon.


Parameters:

string   $locale   —  the new locale to use

[ Top ]

setToken   [line 173]

void setToken( string $token)

Sets the Developer token to use when quering Amazon's Web Services.

Parameters:

string   $token   —  your Developer token

[ Top ]


Documentation generated on Thu, 10 Dec 2015 05:48:05 +0000 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.