定制 amzn-spapi/sdk 二次开发

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

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

amzn-spapi/sdk

最新稳定版本:1.6.0

Composer 安装命令:

composer require amzn-spapi/sdk

包简介

Amazon Selling Partner APIs official client library for PHP.

README 文档

README

The Selling Partner API SDK for PHP enables you to easily connect your PHP application to Amazon's REST-based SP-API.

Getting started

Credentials

Before you can use the SDK, you need to be registered as a Selling Partner API developer. If you haven't done that yet, please follow the instructions in the documentation. You also need to register your application to get valid credentials to call SP-API. If you haven't done that yet, please follow the instructions in the documentation. If you are already registered successfully, you can find instructions on how to view your credentials in the documentation.

Installation & Usage

Minimum Requirements

To run the SDK you need PHP 7.4 or higher.

Manual Installation

By using the download files, composer dependencies are already installed. You only need to include autoload.php:

<?php
require_once('/path/to/OpenAPIClient-php/vendor/autoload.php');

Use the SDK

In order to call one of the APIs included in the Selling Partner API, you need to:

  • Configure credentials and marketplace ids. We provided a .env file to test the SDK in php/sdk/.env
  • Create an instance for a specific API (e.g. Orders API)
  • Call an operation
<?php
require_once(__DIR__ . '/vendor/autoload.php');

use SpApi\AuthAndAuth\LWAAuthorizationCredentials;
use SpApi\AuthAndAuth\LWAAuthorizationSigner;
use SpApi\Api\OrdersApi;
use SpApi\Configuration;


// Set up LWA credentials
$lwaAuthorizationCredentials = new LWAAuthorizationCredentials([
"clientId" => "amzn1.application-**************",
"clientSecret" => "***********",
"refreshToken" => "***********",
"endpoint" => "https://api.amazon.com/auth/o2/token"
]);

// Initialize LWAAuthorizationSigner instance
$lwaAuthorizationSigner = new LWAAuthorizationSigner($lwaAuthorizationCredentials);
$config = new Configuration([], $lwaAuthorizationCredentials);

// Setting SP-API endpoint region
$config->setHost('https://sellingpartnerapi-na.amazon.com');

// Create a new HTTP client
$client = new GuzzleHttp\Client();

// Create an instance of the Orders Api
$api = new OrdersApi($config, null, $client);

try {
// Call getOrders
$result = $api->getOrders(
$marketplace_ids = ['ATVPDKIKX0DER'],
$created_after = '2024-01-01'
);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling OrderApi->getOrders: ', $e->getMessage(), PHP_EOL;
}

Giving Feedback

We need your help in making this SDK great. Please participate in the community and contribute to this effort by submitting issues, participating in discussion forums and submitting pull requests through the following channels:

Submit issues - this is the preferred channel to interact with our team Articulate your feature request or upvote existing ones on our Issues page

Disclaimer

统计信息

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

GitHub 信息

  • Stars: 4
  • Watchers: 4
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 未知

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固