PHP code example of synergy / laravel-amazon-product-api

1. Go to this page and download the library: Download synergy/laravel-amazon-product-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/ */

    

synergy / laravel-amazon-product-api example snippets



use Revolution\Amazon\ProductAdvertising\Facades\AmazonProduct;

# string $category, string $keyword = null, int $page = 1
$response = AmazonProduct::search('All', 'amazon' , 1);
dd($response);
# returns normal array

# string $browse Browse node
$response = AmazonProduct::browse('1');

# string $asin ASIN
$response = AmazonProduct::item('ASIN1');

# array $asin ASIN
$response = AmazonProduct::items(['ASIN1', 'ASIN2']);

# setIdType: support only item() and items()
$response = AmazonProduct::setIdType('EAN')->item('EAN');
# reset to ASIN
AmazonProduct::setIdType('ASIN');
# PA-APIv5 not support EAN?

$response = AmazonProduct::browse('1');
$nodes = data_get($response, 'BrowseNodesResult');
$items = data_get($nodes, 'BrowseNodes.TopSellers.TopSeller');
$asins = data_get($items, '*.ASIN');
$results = AmazonProduct::items($asins);
# PA-APIv5 not support TopSeller?

try {
    $response = AmazonProduct::browse('1');
} catch(ApiException $e) {

}

$response = rescue(function () use ($browse_id) {
                return AmazonProduct::browse($browse_id);
            }, []);
bash
php artisan vendor:publish --tag=amazon-product-config