sellerlegend / amazon-sp-api-php
v2.7.0
2023-04-28 09:05 UTC
Requires
- php: >=7.3
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- guzzlehttp/guzzle: ^6.2|^7.0
Requires (Dev)
- friendsofphp/php-cs-fixer: v2.17.3
- phpunit/phpunit: ^4.8
- roave/security-advisories: dev-master
- squizlabs/php_codesniffer: ~2.6
- dev-master
- v2.7.0
- v2.6.2
- v2.6.1
- v2.6.0
- v2.5.3
- v2.5.2
- v2.5.1
- v2.5.0
- v2.4.0
- v2.3.5
- v2.3.4
- v2.3.3
- v2.3.2
- v2.3.1
- v2.3.0
- v2.2.11
- v2.2.10
- v2.2.9
- v2.2.8
- v2.2.7
- v2.2.6
- v2.2.5
- v2.2.4
- v2.2.3
- v2.2.2
- v2.2.1
- v2.2.0
- v2.1.14
- v2.1.13
- v2.1.12
- v2.1.11
- v2.1.10
- v2.1.9
- v2.1.8
- v2.1.7
- v2.1.6
- v2.1.5
- v2.1.4
- 2.1.3
- 2.1.2
- 2.1.1
- 2.1
- 2.0
- 1.2
- 1.1
- 1.0
- dev-report_api_upgrade
- dev-orders_api_updates
- dev-pricing_api_updates
- dev-orders_buyer_info
- dev-fix/exception
This package is auto-updated.
Last update: 2024-09-28 12:07:31 UTC
README
这是为新的亚马逊销售合作伙伴API提供的PHP API绑定。
这个库基于 swagger-codegen 的输出以及亚马逊提供的 OpenAPI文件,并由贡献者进行了修改。
这个包的目的是通过简单的composer包轻松开始使用亚马逊销售合作伙伴API。
要求
- PHP >= 7.3
- cURL 扩展
- JSON 扩展
- MBString 扩展
安装
只需通过composer要求此包
composer require sellerlegend/amazon-sp-api-php
详细文档
您可以在 docs/Api 目录 中找到此PHP库的详细文档(请注意:命名空间和其他类可能已更改)。
您可以在亚马逊官方开发者网站上找到有关亚马逊销售合作伙伴API的一般信息。
示例
这些都是简单的示例,仅用于展示如何开始调用API。
IAM角色
当您在开发人员配置文件中输入了IAM角色ARN时
<?php require_once './vendor/autoload.php'; $options = [ 'refresh_token' => '', // Aztr|... 'client_id' => '', // App ID from Seller Central, amzn1.sellerapps.app.cfbfac4a-...... 'client_secret' => '', // The corresponding Client Secret 'region' => \SellerLegend\AmazonSellingPartnerAPI\SellingPartnerRegion::$EUROPE, // or NORTH_AMERICA / FAR_EAST 'access_key' => '', // Access Key of AWS IAM User, for example AKIAABCDJKEHFJDS 'secret_key' => '', // Secret Key of AWS IAM User 'endpoint' => \SellerLegend\AmazonSellingPartnerAPI\SellingPartnerEndpoint::$EUROPE, // or NORTH_AMERICA / FAR_EAST 'role_arn' => '', // AWS IAM Role ARN for example: arn:aws:iam::123456789:role/Your-Role-Name ]; $accessToken = \SellerLegend\AmazonSellingPartnerAPI\SellingPartnerOAuth::getAccessTokenFromRefreshToken( $options['refresh_token'], $options['client_id'], $options['client_secret'] ); $assumedRole = \SellerLegend\AmazonSellingPartnerAPI\AssumeRole::assume( $options['region'], $options['access_key'], $options['secret_key'], $options['role_arn'], ); $config = \SellerLegend\AmazonSellingPartnerAPI\Configuration::getDefaultConfiguration(); $config->setHost($options['endpoint']); $config->setAccessToken($accessToken); $config->setAccessKey($assumedRole->getAccessKeyId()); $config->setSecretKey($assumedRole->getSecretAccessKey()); $config->setRegion($options['region']); $config->setSecurityToken($assumedRole->getSessionToken()); $apiInstance = new \SellerLegend\AmazonSellingPartnerAPI\Api\CatalogItemsApi($config); $marketplace_id = 'A1PA6795UKMFR9'; $asin = 'B0002ZFTJA'; $result = $apiInstance->getCatalogItem($marketplace_id, $asin); echo $result->getPayload()->getAttributeSets()[0]->getTitle(); // Never Gonna Give You Up [Vinyl Single]
IAM用户
当您输入了用户ARN而不是角色ARN时,请使用此示例
<?php require_once './vendor/autoload.php'; $options = [ 'refresh_token' => '', // Aztr|... 'client_id' => '', // App ID from Seller Central, amzn1.sellerapps.app.cfbfac4a-...... 'client_secret' => '', // The corresponding Client Secret 'region' => \SellerLegend\AmazonSellingPartnerAPI\SellingPartnerRegion::$EUROPE, // or NORTH_AMERICA / FAR_EAST 'access_key' => '', // Access Key of AWS IAM User, for example AKIAABCDJKEHFJDS 'secret_key' => '', // Secret Key of AWS IAM User 'endpoint' => \SellerLegend\AmazonSellingPartnerAPI\SellingPartnerEndpoint::$EUROPE, // or NORTH_AMERICA / FAR_EAST ]; $accessToken = \SellerLegend\AmazonSellingPartnerAPI\SellingPartnerOAuth::getAccessTokenFromRefreshToken( $options['refresh_token'], $options['client_id'], $options['client_secret'] ); $config = \SellerLegend\AmazonSellingPartnerAPI\Configuration::getDefaultConfiguration(); $config->setHost($options['endpoint']); $config->setAccessToken($accessToken); $config->setAccessKey($options['access_key']); $config->setSecretKey($options['secret_key']); $config->setRegion($options['region']); $apiInstance = new \SellerLegend\AmazonSellingPartnerAPI\Api\CatalogItemsApi($config); $marketplace_id = 'A1PA6795UKMFR9'; $asin = 'B0002ZFTJA'; $result = $apiInstance->getCatalogItem($marketplace_id, $asin); echo $result->getPayload()->getAttributeSets()[0]->getTitle(); // Never Gonna Give You Up [Vinyl Single]
##致谢