edwinmugendi / amazon
Amazon Product Advertising API
Installs: 18
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 2
Open Issues: 2
pkg:composer/edwinmugendi/amazon
Requires
- php: >=4.0.2
This package is auto-updated.
Last update: 2025-11-29 02:43:11 UTC
README
This library wraps the following functions of Amazon's Product Advertising API:
1. ItemSearch2. 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 autoloaduse 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');
- 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();
- Set the parameters using the
$apai->setParam()function
//Set parameters $apai->setParam('SearchIndex', 'All'); $apai->setParam('ResponseGroup', 'Offers'); $apai->setParam('Keywords', 'hp laptop');
- Call the actual function eg ItemSearch
$verbose = true; //Print url sent to Amazon and the results from Amazon $response = $apai->itemSearch($verbose);
- Handle the response. The response is an array with
statusandresponsekeys. If the request is successful,statuswill be1andresponsewill have the xml string that you should parse withSimpleXMLElement, otherwisestatuswill be0andresponsewill 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.