clousale / amazon-sp-api-php
此包已被弃用且不再维护。未建议替代包。
2.1.3
2021-04-21 12:13 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
This package is auto-updated.
Last update: 2022-08-07 20:12:19 UTC
README
该项目不再维护。我们建议使用 jlevers/selling-partner-api 包。
Amazon Selling Partner API PHP
这是用于新 Amazon Selling Partner API 的 PHP API 绑定。
此库基于 Amazon 提供的 OpenAPI 文件 的输出,并由贡献者进行了修改。
此包的目的是通过简单的 composer 包轻松开始使用 Amazon Selling Partner API。
要求
- PHP >= 7.3
- cURL 扩展
- JSON 扩展
- MBString 扩展
安装
只需通过 composer 需求此包
composer require clousale/amazon-sp-api-php
详细文档
您可以在 docs/Api
目录 中找到此 PHP 库的详细文档(请注意:命名空间和其他类可能已更改)
您可以在 官方 Amazon 开发者网站 上找到有关 Amazon Selling Partner 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' => \ClouSale\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' => \ClouSale\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 = \ClouSale\AmazonSellingPartnerAPI\SellingPartnerOAuth::getAccessTokenFromRefreshToken( $options['refresh_token'], $options['client_id'], $options['client_secret'] ); $assumedRole = \ClouSale\AmazonSellingPartnerAPI\AssumeRole::assume( $options['region'], $options['access_key'], $options['secret_key'], $options['role_arn'], ); $config = \ClouSale\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 \ClouSale\AmazonSellingPartnerAPI\Api\CatalogApi($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' => \ClouSale\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' => \ClouSale\AmazonSellingPartnerAPI\SellingPartnerEndpoint::$EUROPE, // or NORTH_AMERICA / FAR_EAST ]; $accessToken = \ClouSale\AmazonSellingPartnerAPI\SellingPartnerOAuth::getAccessTokenFromRefreshToken( $options['refresh_token'], $options['client_id'], $options['client_secret'] ); $config = \ClouSale\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 \ClouSale\AmazonSellingPartnerAPI\Api\CatalogApi($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]
待办事项
- 实现测试
- 改进文档
欢迎提出功能请求和拉取请求!
备注
如果您正在寻找完整的再定价和 FBA-退款解决方案,您可能想尝试一下 ClouSale.com。
感谢
感谢所有为这个包添加 PR 并工作的每个人。