sergo920/amazon-sp-api-php
Composer 安装命令:
composer require sergo920/amazon-sp-api-php
包简介
README 文档
README
This is an API Binding in PHP for the new Amazon Selling Partner API.
This library is based on the output of swagger-codegen with the OpenAPI files provided by Amazon and has been modified by the contributors.
The purpose of this package is to have an easy way of getting started with the Amazon Selling Partner API through a simple composer package.
Requirements
- PHP >= 7.3
- cURL Extension
- JSON Extension
- MBString Extension
Installation
Just require this package via composer:
composer require sergo920/amazon-sp-api-php
Detailed Documentation
You can find detailed documentation for this PHP Library in the docs/Api directory (Please note: Namespaces and other classes could have been changed)
You can find general information about the Amazon Selling Partner API on the official Amazon Developer Website.
Examples
These are simple examples, just to show you how to get started calling the API.
IAM Role
For when you entered the IAM Role ARN in your developer profile:
<?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 User
When you entered the User ARN instead of the Role ARN, please use this example:
<?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]
ToDo
- Implement Tests
- Improve documentation
Feature Requests & Pull Requests are very welcome!
Thanks
Thanks go out to everybody who added PRs and worked on this package.
sergo920/amazon-sp-api-php 适用场景与选型建议
sergo920/amazon-sp-api-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 11.56k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2021 年 06 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「amazon」 「selling-partner」 「sp-api」 「clousale」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 sergo920/amazon-sp-api-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 sergo920/amazon-sp-api-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 sergo920/amazon-sp-api-php 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This package includes a script and fail2ban configuration that allows you to use fail2ban when utilizing AWS elastic load balancer (ELB) and an apache webserver.
A PSR-7 compatible library for making CRUD API endpoints
Magento 2 Social Login extension is designed for quick login to your Magento 2 store without procesing complex register steps
A simple Laravel 5/6/7/8 service provider for including the AWS SDK for PHP.
Amazon Selling Partner API Official Client With fixed
统计信息
- 总下载量: 11.56k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-06-03