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.
composer require rossjcooper/laravel-amazon-products
- For Laravel 5.4 or earlier, in your
config/app.php
file:- Add
Rossjcooper\LaravelAmazonProducts\ServiceProvider::class
to your providers array inconfig/app.php
. - Add
'AmazonProductsAPI' => Rossjcooper\LaravelAmazonProducts\Facades\API::class
to your aliases array inconfig/app.php
.
- Add
php artisan vendor:publish --provider="Rossjcooper\LaravelAmazonProducts\ServiceProvider" --tag="config"
will create aconfig/amazon_products.php
file.- Add your Amazon access and secret keys into the your
.env
file:
AMAZON_PRODUCTS_ACCESS_KEY=youAccessKey
AMAZON_PRODUCTS_PRIVATE_KEY=youPrivateKey
- Optionally update your host and region values in the
config/amazon_products.php
file.
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
We're using the brilliant Orchestra Testbench v4 to run unit tests in a Laravel based environment.
Please only report issues relating to the Laravel side of things here, main API issues should be reported here