PHP code example of highsidelabs / amazon-business-api
1. Go to this page and download the library: Download highsidelabs/amazon-business-api library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
highsidelabs / amazon-business-api example snippets
$config = new AmazonBusinessApi\Configuration([
'lwaClientId' => '<LWA client ID>',
'lwaClientSecret' => '<LWA client secret>',
'lwaRefreshToken' => '<LWA refresh token>',
'awsAccessKeyId' => '<AWS access key ID>',
'awsSecretAccessKey' => '<AWS secret access key>',
// If you're not working in the North American marketplace, change
// this to another endpoint from lib/Endpoint.php
'endpoint' => AmazonBusinessApi\Endpoint::NA,
]);
$config = new AmazonBusinessApi\Configuration([
'lwaClientId' => '<LWA client ID>',
'lwaClientSecret' => '<LWA client secret>',
'lwaRefreshToken' => '<LWA refresh token>',
'awsAccessKeyId' => '<AWS access key ID>',
'awsSecretAccessKey' => '<AWS secret access key>',
// If you're not working in the North American marketplace, change
// this to another endpoint from lib/Endpoint.php
'endpoint' => AmazonBusinessApi\Endpoint::NA,
'roleArn' => '<Role ARN>',
]);
AmazonBusinessApi\Api\ProductSearchV20200826Api as ProductSearchApi;
use AmazonBusinessApi\Configuration;
use AmazonBusinessApi\Endpoint;
$config = new Configuration([
'lwaClientId' => 'amzn1.application-oa2-client.....',
'lwaClientSecret' => 'abcd....',
'lwaRefreshToken' => 'Aztr|IwEBI....',
'awsAccessKeyId' => 'AKIA....',
'awsSecretAccessKey' => 'ABCD....',
// If you're not working in the North American marketplace, change
// this to another endpoint from lib/Endpoint.php
'endpoint' => Endpoint::NA
]);
$api = new ProductSearchApi($config);
try {
$result = $api->productsRequest('B0B96H7LGX', 'US', 'en_US', '[email protected]');
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling ProductSearchApi->productsRequest: ', $e->getMessage(), PHP_EOL;
}
AmazonBusinessApi\Configuration;
$config = new Configuration([/* ... */]);
$config->setDebug(true);
// To redirect debug info to a file:
$config->setDebugFile('./debug.log');
use AmazonBusinessApi\Api\ProductSearchV20200826Api as ProductSearchApi;
use AmazonBusinessApi\Model\ProductSearchV20200826 as ProductSearch;