定制 andrewyj/amazon-sp-api 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

andrewyj/amazon-sp-api

Composer 安装命令:

composer require andrewyj/amazon-sp-api

包简介

Amazon selling partner sdk

README 文档

README

SP-API is the next-generation API functionality suite for sellers and their agents to sell their products on the Amazon marketplace efficiently. Amazon Marketplace Web Services (Amazon MWS) APIs preceded SP-APIs and have been utilized extensively for over ten years. Amazon states in their documentation that the SP-API is the future and that SP APIs will receive any new updates and enhancements. However, one can expect a transition period from MWS to SP-API while the new system is stabilized and offers parity with the existing MWS APIs.

For more information visit: https://github.com/amzn/selling-partner-api-docs

Installation

composer require andrewyj/amazon-sp-api

Basic Usage

1. Define auth info

$auth = [
    'refresh_token' => '', // Aztr|...
    'client_id' => '', // App ID from Seller Central, amzn1.sellerapps.app.cfbfac4a-......
    'client_secret' => '', // The corresponding Client Secret
    'region' => \AmazonSellingPartnerAPI\Client::REGION_NORTH_AMERICA, 
    'access_key' => '', // Access Key of AWS IAM User, for example AKIAABCDJKEHFJDS
    'secret_key' => '', // Secret Key of AWS IAM User
    'role_arn' => '', // AWS IAM Role ARN for example: arn:aws:iam::123456789:role/Your-Role-Name
];

2. Use refresh_token to exchange access_token

$oAuth = new \AmazonSellingPartnerAPI\OAuth($auth['client_id'], $auth['client_secret']);
$auth['access_token'] = $oAuth->getAccessToken($auth['refresh_token'])->access_token;

3. Select a signature version(v4)

$sign = new \AmazonSellingPartnerAPI\Signature\V4Signature();

4. Fetch role info

$assumedRole = new \AmazonSellingPartnerAPI\AssumeRole($auth['region'], $auth['access_key'], $auth['secret_key'], $sign);
$credentials = $assumedRole->assume($auth['role_arn']);
$auth['access_key'] = $credentials['AccessKeyId'];
$auth['secret_key'] = $credentials['SecretAccessKey'];
$auth['session_token'] = $credentials['SessionToken'];

5. Make a request

$client = new \AmazonSellingPartnerAPI\Client($sign);
$client->setAuth($auth);
var_dump($client->get('/orders/v0/orders/XXX-XXXXXX-XXXXXXX'));

Module usage

1. Define auth info

Define auth info

2. Select a module

$sign = new \AmazonSellingPartnerAPI\Signature\V4Signature();
$cache = new Cache();
$order = new \AmazonSellingPartnerAPI\Module\Order($auth, $cache, $sign);

Cache() are used to cache role credentials and access_token.It must have get() and set() functions. if you don't have one. create an adapter.

3. Make a request

# route param
var_dump($order->getOrder('XXX-XXXXXX-XXXXXXX')->send());

# query param
var_dump($order->getOrders()->withQuery([
  "CreatedAfter" => "2020-04-13T06:28:08Z",
  "MarketplaceIds" => [
      "XXXXXX",
  ]
])->send());

统计信息

  • 总下载量: 23
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2021-07-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固