Wallogit.com
2017 © Pedro Peláez
Amazon Product Advertising API
This library wraps the following functions of Amazon's Product Advertising API:, (*1)
require_once __DIR__ . '/../vendor/autoload.php'; // Autoload files using Composer autoload use Edwinmugendi\Amazon\Apai; $apai = new Apai();
$apai->setConfig() function//Set configs
$apai->setConfig('ApiKey', 'XXXXX');
$apai->setConfig('ApiSecret', 'XXXX');
$apai->setConfig('AssociativeTag', 'XXXX');
$apai->setConfig('EndPoint', 'webservices.amazon.de');
//Reset parameters first. This is important if you are looping through items $apai->resetParam();
$apai->setParam() function//Set parameters
$apai->setParam('SearchIndex', 'All');
$apai->setParam('ResponseGroup', 'Offers');
$apai->setParam('Keywords', 'hp laptop');
$verbose = true; //Print url sent to Amazon and the results from Amazon $response = $apai->itemSearch($verbose);
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)