Amazon SP-API PHP 项目教程

Amazon SP-API PHP 项目教程

amazon-sp-api-phpThis is an API Binding in PHP for the new Amazon Selling Partner API.项目地址:https://gitcode.com/gh_mirrors/am/amazon-sp-api-php

1. 项目的目录结构及介绍

amazon-sp-api-php/
├── composer.json
├── composer.lock
├── examples/
│   ├── config.php
│   ├── getOrders.php
│   ├── getOrderItems.php
│   └── ...
├── src/
│   ├── Api/
│   │   ├── AuthorizationApi.php
│   │   ├── CatalogItemsApi.php
│   │   ├── ...
│   ├── Client/
│   │   ├── ApiClient.php
│   │   ├── Configuration.php
│   │   ├── ...
│   ├── Model/
│   │   ├── AuthorizationCode.php
│   │   ├── CatalogItem.php
│   │   ├── ...
│   └── ...
├── tests/
│   ├── Api/
│   │   ├── AuthorizationApiTest.php
│   │   ├── CatalogItemsApiTest.php
│   │   ├── ...
│   ├── Client/
│   │   ├── ApiClientTest.php
│   │   ├── ConfigurationTest.php
│   │   ├── ...
│   └── ...
└── ...

目录结构介绍

  • composer.jsoncomposer.lock:Composer 依赖管理文件。
  • examples/:包含示例代码,如 config.phpgetOrders.php 等。
  • src/:项目的源代码目录,包含 API、客户端和模型等。
    • Api/:包含各个 API 接口的实现。
    • Client/:包含客户端配置和请求处理等。
    • Model/:包含数据模型的定义。
  • tests/:包含单元测试代码。

2. 项目的启动文件介绍

examples/ 目录下,有多个示例文件,其中 getOrders.php 是一个典型的启动文件示例。

getOrders.php 文件介绍

<?php
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/config.php';

use ClouSale\AmazonSellingPartnerAPI\Api\OrdersApi;
use ClouSale\AmazonSellingPartnerAPI\Configuration;
use ClouSale\AmazonSellingPartnerAPI\ApiException;

$config = new Configuration();
$config->setHost($endpoint);
$config->setAccessToken($access_token);
$config->setRegion($region);

$ordersApi = new OrdersApi($config);

try {
    $result = $ordersApi->getOrders($marketplace_ids, $created_after, $created_before, $last_updated_after, $last_updated_before, $order_statuses, $fulfillment_channels, $payment_methods, $buyer_email, $seller_order_id, $max_results_per_page, $easy_ship_shipment_statuses, $next_token, $amazon_order_ids, $actual_fulfillment_supply_source_id, $is_ispu, $store_chain_store_id);
    print_r($result);
} catch (ApiException $e) {
    echo 'Exception when calling OrdersApi->getOrders: ', $e->getMessage(), PHP_EOL;
}

启动文件说明

  • 引入必要的依赖和配置文件。
  • 创建 Configuration 对象并设置相关参数。
  • 实例化 OrdersApi 对象。
  • 调用 getOrders 方法获取订单数据,并处理可能的异常。

3. 项目的配置文件介绍

examples/ 目录下,config.php 是主要的配置文件。

config.php 文件介绍

<?php
$endpoint = 'https://sellingpartnerapi-na.amazon.com';
$access_token = 'your_access_token';
$region = 'us-east-1';
$marketplace_ids = ['ATVPDKIKX0DER'];
$created_after = '2023-01-01T00:00:00Z';
$created_before = '2023-12-31T23:59:59Z';
$last_updated_after = '2023-01-01T00:

amazon-sp-api-phpThis is an API Binding in PHP for the new Amazon Selling Partner API.项目地址:https://gitcode.com/gh_mirrors/am/amazon-sp-api-php

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

翟舟琴Jacob

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值