PHP code example of tims / amazon-creatorsapi-php-sdk
1. Go to this page and download the library: Download tims/amazon-creatorsapi-php-sdk 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/ */
tims / amazon-creatorsapi-php-sdk example snippets
use Amazon\CreatorsAPI\v1\Configuration;
use Amazon\CreatorsAPI\v1\com\amazon\creators\api\DefaultApi;
use Amazon\CreatorsAPI\v1\com\amazon\creators\model\GetItemsRequestContent;
use Amazon\CreatorsAPI\v1\com\amazon\creators\model\GetItemsResource;
$config = new Configuration();
$config->setCredentialId('<YOUR CREDENTIAL ID>');
$config->setCredentialSecret('<YOUR CREDENTIAL SECRET>');
$config->setVersion('<YOUR CREDENTIAL VERSION>');
$api = new DefaultApi(null, $config);
$request = new GetItemsRequestContent();
$request->setPartnerTag('<YOUR PARTNER TAG>');
$request->setItemIds(['B0XXXX']);
$request->setResources([
GetItemsResource::ITEM_INFO_TITLE,
GetItemsResource::IMAGES_PRIMARY_MEDIUM,
]);
$response = $api->getItems('www.amazon.com', $request);
class CachedDefaultApi extends DefaultApi
{
protected function createTokenManager(OAuth2Config $oauthConfig): OAuth2TokenManager
{
return new MyCachedTokenManager($oauthConfig);
}
}
bash
cd examples
php SampleGetItems.php
php SampleSearchItems.php
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.