The Selling Partner API for Listings Items (Listings Items API) provides programmatic access to selling partner listings on Amazon. Use this API in collaboration with the Selling Partner API for Product Type Definitions, which you use to retrieve the information about Amazon product types needed to use the Listings Items API. For more information, see the Listings Items API Use Case Guide.
This PHP package is automatically generated by the Swagger Codegen project:
- API version: 2021-08-01
- Build package: io.swagger.codegen.v3.generators.php.PhpClientCodegen For more information, please visit https://sellercentral.amazon.com/gp/mws/contactus.html
public function getAccessToken($channel_account): string
{
$refresh_token = $channel_account->getAuthDetail('refresh_token');
if (!$refresh_token) {
throw new AmazonSPAPIOAuthException('Invalid refresh_token');
}
return AmazonSPAPIOAuth::getAccessTokenFromRefreshToken(
$refresh_token,
$this->client_id,
$this->client_secret
);
}
public function prepareRequestConfig($channel_account, $token): array
{
$auth_details = $channel_account->getAuthDetail();
$region_key = $auth_details['region'];
$region = AmazonSPAPIRegion::$$region_key;
$endpoint = AmazonSPAPIEndpoint::$$region_key;
$assumedRole = AssumeRole::assume(
$region,
$this->iam_user_access_key,
$this->iam_user_secret_key,
$this->iam_role_arn,
);
$config = Configuration::getDefaultConfiguration();
$config->setAccessToken($token);
$config->setAccessKey($assumedRole->getAccessKeyId());
$config->setSecretKey($assumedRole->getSecretAccessKey());
$config->setRegion($region);
$config->setSecurityToken($assumedRole->getSessionToken());
return $config;
}