laravel-amazon-products maintained by rossjcooper
Description
A Laravel wrapper for the Amazon Products API SDK
Author
Last update
2022/07/06 22:32
(dev-master)
License
Downloads
31
Amazon Products API SDK Wrapper for Laravel
This is a wrapper for the rossjcooper/paapiphpsdk package and gives the user a Service Container binding and facade a configured instance of the Amazon\ProductAdvertisingAPI\v1\com\amazon\paapi5\v1\api\DefaultApi class.
Installation
composer require rossjcooper/laravel-amazon-products- For Laravel 5.4 or earlier, in your
config/app.phpfile:- Add
Rossjcooper\LaravelAmazonProducts\ServiceProvider::classto your providers array inconfig/app.php. - Add
'AmazonProductsAPI' => Rossjcooper\LaravelAmazonProducts\Facades\API::classto your aliases array inconfig/app.php.
- Add
php artisan vendor:publish --provider="Rossjcooper\LaravelAmazonProducts\ServiceProvider" --tag="config"will create aconfig/amazon_products.phpfile.- Add your Amazon access and secret keys into the your
.envfile:
AMAZON_PRODUCTS_ACCESS_KEY=youAccessKey
AMAZON_PRODUCTS_PRIVATE_KEY=youPrivateKey
- Optionally update your host and region values in the
config/amazon_products.phpfile.
Usage
public function handle(\Rossjcooper\LaravelAmazonProducts\API $api)
{
$request = new SearchItemsRequest();
$request->setSearchIndex('All');
$request->setKeywords('Harry Potter');
$request->setResources([
SearchItemsResource::ITEM_INFOTITLE,
SearchItemsResource::OFFERSLISTINGSPRICE,
]);
$request->setPartnerTag(config('mypartnertag'));
$request->setPartnerType(config('Associates'));
$response = $api->searchItems($request);
foreach($response->getSearchResult()->getItems() as $item) {
//...
}
}
For more info on using the actual SDK see the main repo rossjcooper/paapiphpsdk
Testing
We're using the brilliant Orchestra Testbench v4 to run unit tests in a Laravel based environment.
Issues
Please only report issues relating to the Laravel side of things here, main API issues should be reported here