toancong/amazon-mws-laravel

使用 Amazon 的 MWS 网络服务与 Laravel 5.x。基于 creacoon/amazon-mws-laravel 包并修改以兼容最新的 Laravel 版本(+ 错误修复)。

v5.0.4 2021-01-13 09:11 UTC

README

Build Status StyleCI

Amazon MWS for Laravel

============

用于连接 Amazon 商户网络服务(MWS)的 Laravel 5 包。

不是用于 Amazon Web 服务(AWS)- 云计算服务。

此包是从以下地址分叉而来:[https://github.com/keithbrink/amazon-mws-laravel](https://github.com/keithbrink/amazon-mws-laravel),修复了一些错误并添加了更多关于

  • setConfig
  • AmazonShipment
  • AmazonTransport
  • AmazonTransportDocument
  • OrderXXX

安装

使用 composer require toancong/amazon-mws-laravel 安装此包。

对于 Laravel 5.5 及更高版本,包将被自动发现。对于其他版本,您可以将 KeithBrink\AmazonMws\MwsServiceProvider 添加到您的 config/app.php 文件中。

运行 php artisan vendor:publish keithbrink/amazon-mws-laravelamazon-mws.php 配置文件添加到您的配置目录中。

使用方法

使用其中一个对象的一般工作流程如下

  1. 创建一个用于执行所需任务的对象。
  2. 使用 set____ 方法加载参数,具体取决于对象。
  3. 向 Amazon 提交请求。用于此的操作通常命名为 fetch____submit____ 且没有参数。
  4. 使用 get____ 方法引用返回的数据,无论是单个值还是批量。
  5. 使用内置的日志系统监控库的性能。

请注意,如果您想要操作多个 Amazon 店铺,您需要为每个店铺创建一个单独的对象。

此外,请注意,当对象不被视为可重用时,它们表现最佳。否则,如果新的请求失败,您可能会获取旧的数据响应。

如果您想了解如何使用特定功能,最好的方法是阅读功能上面的注释;它们详细且有帮助。

动态配置

如果您想要将用于 Amazon 调用的配置信息更改为与配置文件中的信息不同,您可以在任何调用中添加 setConfig($config) 函数。参数 $config 应该是一个数组,遵循以下模板

$config = [
    'merchantId' => '',
    'marketplaceId' => '',
    'keyId' => '',
    'secretKey' => '',
    'amazonServiceUrl' => '',
];

示例用法

这里有一些库的使用示例。

以下是一个示例函数,用于获取过去 24 小时内更新的所有仓库配送订单

use KeithBrink\AmazonMws\AmazonOrderList;

function getAmazonOrders() {
    $amz = new AmazonOrderList("myStore"); //store name matches the array key in the config file
    $amz->setLimits('Modified', "- 24 hours");
    $amz->setFulfillmentChannelFilter("MFN"); //no Amazon-fulfilled orders
    $amz->setOrderStatusFilter(
        array("Unshipped", "PartiallyShipped", "Canceled", "Unfulfillable")
        ); //no shipped or pending
    $amz->setUseToken(); //Amazon sends orders 100 at a time, but we want them all
    $amz->fetchOrders();
    return $amz->getList();
}

此示例显示了用于将先前创建的 XML 馈送发送到 Amazon 以更新库存编号的函数,并包含了一个动态配置示例

use KeithBrink\AmazonMws\AmazonFeed;

function sendInventoryFeed($feed) {
    $config = [
        'merchantId' => '',
        'marketplaceId' => '',
        'keyId' => '',
        'secretKey' => '',
        'amazonServiceUrl' => '',
    ];

    $amz = new AmazonFeed("myStore"); //store name matches the array key in the config file
    $amz->setConfig($config);
    $amz->setFeedType("_POST_INVENTORY_AVAILABILITY_DATA_"); //feed types listed in documentation
    $amz->setFeedContent($feed);
    $amz->submitFeed();
    return $amz->getResponse();
}

致谢

此包是从以下地址分叉而来:https://github.com/keithbrink/amazon-mws-laravel

它来自:https://github.com/sonnenglas/amazon-mws-laravel

它来自:https://github.com/creacoon/amazon-mws-laravel

它来自:https://github.com/CPIGroup/phpAmazonMWS

该包的原始创建者。