bricre / amazon-selling-partner-sdk-aplus-content
由Amazon Selling Partner API的A+内容管理OpenAPI定义生成的API客户端
2020.11.01
2022-06-14 10:35 UTC
Requires
- allansun/openapi-runtime: ^2.1
Requires (Dev)
- allansun/openapi-code-generator: ^0.2.5
- allansun/openapi-parser: ^2.1.4
This package is auto-updated.
Last update: 2024-09-14 15:58:11 UTC
README
使用Amazon的Swagger文件通过allansun/openapi-code-generator生成的代码。
生成的代码具有良好的自文档,带有适当的PHPDoc注释。
请参考Amazon的文档以获取详细的API行为说明。
安装
composer require bricre/amazon-selling-partner-sdk-aplus-content
您还需要一个基于PSR-7的客户端或Symfony的HTTP Foundation基于客户端
所以可以使用Guzzle(或任何其他PSR-7兼容的客户端)
composer require guzzlehttp/guzzle
或 Symfony HTTP客户端
composer require symfony/http-client
版本控制
此项目与Amazon的API版本控制相匹配。
由于Composer的限制,版本号如'2021-01-01'将更改为'2021.01.01'。
如果您发现没有可用的匹配版本,请联系作者生成针对正确版本的内容。
用法
首先,您需要使用所需的凭据和预定义的响应类型配置OpenAPI\RunTime\Client。您只需这样做一次(或创建一个依赖注入服务)。
您还可能想查看Amazon关于如何授权您的请求的文档。
<?php use Amz\AplusContent\ResponseTypes; use OpenAPI\Runtime\Client; use OpenAPI\Runtime\SimplePsrResponseHandlerStack; Client::configure( new \GuzzleHttp\Client([ 'base_uri' => 'https://sellingpartnerapi-na.amazon.com/', 'headers'=>[ 'Authorization'=> 'Bearer <accessToken>' ] ]), new SimplePsrResponseHandlerStack(new ResponseTypes()) );
然后在您的业务逻辑中,您可以直接调用API操作
<?php use Amz\AplusContent\Api\AplusContent; use Ebay\Sell\Account\Api\Program; $api = new AplusContent(); $docs = $api->searchContentDocuments(['marketplaceId'=>'xxxxxx']);
作者
- Allan Sun - 初始工作