There is no license information available for the latest version (dev-master) of this package.

Amazon Product Advertising API

dev-master 2016-09-25 14:32 UTC

This package is auto-updated.

Last update: 2025-04-29 01:13:50 UTC


README

This library wraps the following functions of Amazon's Product Advertising API:

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 ```php require_once __DIR__ . '/../vendor/autoload.php'; // Autoload files using Composer autoload

use Edwinmugendi\Amazon\Apai;

$apai = new Apai();

2. Set the following 4 configs using the <code>$apai->setConfig()</code> function
```php
//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.

Contact me on edwinmugendi@gmail.com if you need any assistance.