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

Class: Services_Amazon

Source Location: /Services_Amazon-0.9.0/Services/Amazon.php

Class Overview


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


Author(s):

Version:

  • Release: 0.9.0

Methods


Inherited Variables

Inherited Methods


Class Details

[line 103]
Class for accessing and retrieving information from Amazon's Web Services


[ Top ]


Method Detail

Services_Amazon (Constructor)   [line 248]

Services_Amazon Services_Amazon( string $access_key_id, string $secret_access_key, [string $associate_tag = null])

Constructor

Parameters:

string   $access_key_id     An Amazon Access Key ID used when quering Amazon servers
string   $secret_access_key     An Amazon Secret Access Key used when quering Amazon servers
string   $associate_tag     An Amazon Associate Tag used in the URL's so a commision may be payed

[ Top ]

BrowseNodeLookup   [line 549]

array BrowseNodeLookup( string $browsenode_id, [array $options = array()])

Retrieves information about a browse node

Example:

  1.  <?php
  2.  $amazon = new Services_Amazon('[your Access Key ID here]''[your Secret Access key here]');
  3.  $result $amazon->BrowseNodeLookup('283155')// 283155='Books'
  4.  ?>

  • Return: The array of information returned by the query
  • Access: public

Parameters:

string   $browsenode_id     The browse node ID
array   $options     The optional parameters

[ Top ]

CartAdd   [line 580]

array CartAdd( string $cart_id, string $hmac, array $item, [array $options = array()])

Adds items to an existing remote shopping cart

Example:

  1.  <?php
  2.  $amazon = new Services_Amazon('[your Access Key ID here]''[your Secret Access key here]');
  3.  $item = array('ASIN' => 'aaaaaaaaaa''Quantity' => 1);
  4.  // $item = array(array('ASIN' => 'aaaaaaaaaa', 'Quantity' => 1),
  5.  //               array('OfferListingId' => 'bbbbbbbbbb', 'Quantity' => 10),
  6.  //               array('ASIN' => 'cccccccccc', 'Quantity' => 20));
  7.  $result $amazon->CartAdd('[Cart ID]''[HMAC]'$item);
  8.  ?>


Parameters:

string   $cart_id     A unique identifier for a cart
string   $hmac     A unique security token
array   $item     Products and the quantities
array   $options     The optional parameters

[ Top ]

CartClear   [line 600]

array CartClear( string $cart_id, string $hmac, [array $options = array()])

Removes all the contents of a remote shopping cart

Parameters:

string   $cart_id     A unique identifier for a cart
string   $hmac     A unique security token
array   $options     The optional parameters

[ Top ]

CartCreate   [line 629]

array CartCreate( array $item, [array $options = array()])

Creates a new remote shopping cart

Example:

  1.  <?php
  2.  $amazon = new Services_Amazon('[your Access Key ID here]''[your Secret Access key here]');
  3.  $item = array('ASIN' => 'aaaaaaaaaa''Quantity' => 1);
  4.  // $item = array(array('ASIN' => 'aaaaaaaaaa', 'Quantity' => 1),
  5.  //               array('ASIN' => 'cccccccccc', 'Quantity' => 20));
  6.  $result $amazon->CartCreate($item);
  7.  ?>


Parameters:

array   $item     Products and the quantities
array   $options     The optional parameters

[ Top ]

CartGet   [line 647]

array CartGet( string $cart_id, string $hmac, [array $options = array()])

Retrieves the contents of a remote shopping cart

Parameters:

string   $cart_id     A unique identifier for a cart
string   $hmac     A unique security token
array   $options     The optional parameters

[ Top ]

CartModify   [line 679]

array CartModify( string $cart_id, string $hmac, array $item, [array $options = array()])

Modifies the quantity of items in a cart and changes cart items to saved items

Example:

  1.  <?php
  2.  $amazon = new Services_Amazon('[your Access Key ID here]''[your Secret Access key here]');
  3.  $item = array('CartItemId' => 'aaaaaaaaaa''Quantity' => 1);
  4.  // $item = array('CartItemId' => 'aaaaaaaaaa', 'Action' => 'SaveForLater');
  5.  // $item = array(array('CartItemId' => 'aaaaaaaaaa', 'Quantity' => 1),
  6.  //               array('CartItemId' => 'cccccccccc', 'Quantity' => 20));
  7.  $result $amazon->CartModify('[Cart ID]''[HMAC]'$item);
  8.  ?>


Parameters:

string   $cart_id     A unique identifier for a cart
string   $hmac     A unique security token
array   $item     The CartItemId and the quantities or the Action
array   $options     The optional parameters

[ Top ]

doBatch   [line 789]

array doBatch( string $operation, array $shared, [array $params1 = array()], [array $params2 = array()])

Combines requests for the same operation into a single request

Example:

  1.  <?php
  2.  $amazon = new Services_Amazon('[your Access Key ID here]''[your Secret Access key here]');
  3.  $shared = array('SearchIndex' => 'Books',
  4.                  'Keywords' => 'php');
  5.  $params1 = array('ItemPage' => '1');
  6.  $params2 = array('ItemPage' => '2');
  7.  $result $amazon->doBatch('ItemSearch'$shared$params1$params2);
  8.  ?>

  • Return: The array of information returned by the query
  • Access: public

Parameters:

string   $operation     The operation
array   $shared     Shared parameters
array   $params1     The parameters specific to the first request
array   $params2     The parameters specific to the second request

[ Top ]

getApiVersion   [line 262]

string getApiVersion( )

Retrieves the current version of this classes API
  • Return: The API version
  • Access: public

[ Top ]

getError   [line 495]

array getError( )

Retrieves the error code and message

  1.  if (PEAR::isError($result)) {
  2.      $error $amazon->getError();
  3.      echo $error['Code'];
  4.      echo $error['Message'];
  5.  }

  • Return: All errors
  • Access: public

[ Top ]

getErrors   [line 476]

array getErrors( )

Retrieves all error codes and messages

  1.  if (PEAR::isError($result)) {
  2.      foreach ($amazon->getErrors(as $error{
  3.          echo $error['Code'];
  4.          echo $error['Message'];
  5.      }
  6.  }

  • Return: All errors
  • Access: public

[ Top ]

getLastUrl   [line 517]

string getLastUrl( )

Retrieves the last URL accessed to the Amazon (for debugging)
  • Return: The Last URL
  • Access: public

[ Top ]

getProcessingTime   [line 506]

string getProcessingTime( )

Retrieves the processing time
  • Return: Processing time
  • Access: public

[ Top ]

getRawResult   [line 528]

string getRawResult( )

Retrieves the raw result
  • Return: The raw result
  • Access: public

[ Top ]

ItemLookup   [line 708]

array ItemLookup( string $item_id, [array $options = array()])

Retrieves information for products

Example:

  1.  <?php
  2.  $amazon = new Services_Amazon('[your Access Key ID here]''[your Secret Access key here]');
  3.  $options = array();
  4.  $options['ResponseGroup''Large';
  5.  $result $amazon->ItemLookup('[ASIN(s)]'$options);
  6.  ?>


Parameters:

string   $item_id     Product IDs
array   $options     The optional parameters

[ Top ]

ItemSearch   [line 740]

array ItemSearch( string $search_index, [array $options = array()])

Searches for products

Example:

  1.  <?php
  2.  $amazon = new Services_Amazon('[your Access Key ID here]''[your Secret Access key here]');
  3.  $options = array();
  4.  $options['Keywords''sushi';
  5.  $options['Sort''salesrank';
  6.  $options['ResponseGroup''ItemIds,ItemAttributes,Images';
  7.  $result $amazon->ItemSearch('Books'$options);
  8.  ?>


Parameters:

string   $search_index     A search index
array   $options     The optional parameters

[ Top ]

setAccessKeyID   [line 274]

void setAccessKeyID( string $access_key_id)

Sets an Access Key ID
  • Access: public

Parameters:

string   $access_key_id     An Access Key ID

[ Top ]

setAssociateID   [line 321]

void setAssociateID( string $associd)

Sets an Associate ID
  • Access: public

Parameters:

string   $associd     An Associate ID

[ Top ]

setAssociateTag   [line 310]

void setAssociateTag( string $associate_tag)

Sets an Associate Tag
  • Access: public

Parameters:

string   $associate_tag     An Associate Tag

[ Top ]

setBaseUrl   [line 333]

void setBaseUrl( string $url)

Sets the base URL
  • Access: public

Parameters:

string   $url     The base url

[ Top ]

setCache   [line 397]

mixed setCache( [string $container = 'file'], [array $container_options = array()])

Enables caching the data

Requires Cache to be installed. Example:

  1.  <?php
  2.  $amazon = new Services_Amazon('[your Access Key ID here]''[your Secret Access key here]');
  3.  $amazon->setCache('file'array('cache_dir' => 'cache/'));
  4.  $amazon->setCacheExpire(86400)// 86400 seconds = 24 hours
  5.  $result $amazon->BrowseNodeLookup('283155');
  6.  ?>


Parameters:

string   $container     Name of container class
array   $container_options     Array with container class options

[ Top ]

setCacheExpire   [line 428]

void setCacheExpire( integer $secs)

Sets cache expire time

Amazon dictates that any prices that are displayed that may be over an hour old should be accompanied by some sort of timestamp. You can get around that by expiring any queries that use the time in an hour (3600 seconds).


Parameters:

integer   $secs     Expire time in seconds

[ Top ]

setLocale   [line 347]

mixed setLocale( string $locale)

Sets the locale passed when making a query to Amazon

Currently US, UK, DE, JP, FR, and CA are supported

  • Return: A PEAR_Error on error, a true on success
  • Access: public

Parameters:

string   $locale     The new locale to use

[ Top ]

setProxy   [line 442]

void setProxy( string $host, [int $port = 8080], [string $user = null], [string $pass = null])

Sets a proxy
  • Access: public

Parameters:

string   $host     Proxy host
int   $port     Proxy port
string   $user     Proxy username
string   $pass     Proxy password

[ Top ]

setSecretAccessKey   [line 298]

void setSecretAccessKey( $secret_access_key, string $subid)

Sets a Secret Access Key
  • Access: public

Parameters:

string   $subid     A Secret Access Key
   $secret_access_key     

[ Top ]

setSubscriptionID   [line 286]

void setSubscriptionID( string $subid)

Sets a Subscription ID (for backward compatibility)
  • Access: public

Parameters:

string   $subid     A Subscription ID

[ Top ]

setTimestamp   [line 456]

void setTimestamp( integer $time)

Sets a timestamp (for debugging)
  • Access: public

Parameters:

integer   $time     A timestamp

[ Top ]

setVersion   [line 372]

void setVersion( string $version)

Sets a version
  • Access: public

Parameters:

string   $version     A service version

[ Top ]

SimilarityLookup   [line 756]

array SimilarityLookup( string $item_id, [array $options = array()])

Retrieves products that are similar to Amazon products
  • Return: The array of information returned by the query
  • Access: public

Parameters:

string   $item_id     Product IDs
array   $options     The optional parameters

[ Top ]


Documentation generated on Thu, 22 Dec 2011 13:00:03 +0000 by phpDocumentor 1.4.3. PEAR Logo Copyright © PHP Group 2004.