2017 © Pedro Peláez
 

library amazon

Amazon Product Advertising API

image

edwinmugendi/amazon

Amazon Product Advertising API

  • Sunday, September 25, 2016
  • by edwinmugendi
  • Repository
  • 2 Watchers
  • 1 Stars
  • 12 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 2 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Amazon Product Advertising API wrapper

This library wraps the following functions of Amazon's Product Advertising API:, (*1)

  1. ItemSearch
  2. BrowseNodeLookup
  3. ItemLookup
  4. SimilarityLookup
  5. CartAdd
  6. CartClear
  7. CartCreate
  8. CartGet
  9. CartModify

Usage

  1. Load and initialize Apai Class
require_once __DIR__ . '/../vendor/autoload.php'; // Autoload files using Composer autoload

use Edwinmugendi\Amazon\Apai;

$apai = new Apai();
  1. Set the following 4 configs using the $apai->setConfig() function
//Set configs
$apai->setConfig('ApiKey', 'XXXXX');
$apai->setConfig('ApiSecret', 'XXXX');
$apai->setConfig('AssociativeTag', 'XXXX');
$apai->setConfig('EndPoint', 'webservices.amazon.de');
  1. If you are looping via a list of items, you might need to reset the parameters. This basically removes any preset parameters
//Reset parameters first. This is important if you are looping through items
$apai->resetParam();
  1. Set the parameters using the $apai->setParam() function
//Set parameters
$apai->setParam('SearchIndex', 'All');
$apai->setParam('ResponseGroup', 'Offers');
$apai->setParam('Keywords', 'hp laptop');
  1. Call the actual function eg ItemSearch
$verbose = true; //Print url sent to Amazon and the results from Amazon
$response = $apai->itemSearch($verbose);
  1. Handle the response. The response is an array with status and response keys. If the request is successful, status will be 1 and response will have the xml string that you should parse with SimpleXMLElement, otherwise status will be 0 and response will have the error message.
if ($response['status']) {
    $item_lookup_xml = new \SimpleXMLElement($response['response']);
} else {
    echo $response['response'];
}//E# if else statement

For sample code of every function, check the tests folder., (*2)

Contact me on edwinmugendi@gmail.com if you need any assistance., (*3)

The Versions

25/09 2016

dev-master

9999999-dev

Amazon Product Advertising API

  Sources   Download

The Requires

  • php >=4.0.2

 

by Edwin Mugendi