keithbrink / amazon-mws-laravel
Requires
- php: >=7.3
- ext-curl: *
- illuminate/support: ^8.0|^9.0|^10.0
- symfony/http-kernel: ^5.0|^6.0
Requires (Dev)
- illuminate/http: ^9.0|^10.0
- illuminate/routing: ^9.0|^10.0
- illuminate/view: ^9.0|^10.0
- mockery/mockery: ^1.3.1
- phpunit/phpunit: ^9.0
- vlucas/phpdotenv: ^5.0
- dev-master
- 8.x-dev
- 8.2.0
- 8.1.1
- 8.1.0
- 8.0.6
- 8.0.5
- 8.0.4
- 8.0.3
- 8.0.2
- 8.0.1
- 8.0.0
- 7.x-dev
- 7.2.1
- 7.2.0
- 7.1.9
- 7.1.8
- 7.1.7
- 7.1.6
- 7.1.5
- 7.1.4
- 7.1.3
- 7.1.2
- 7.1.1
- 7.1.0
- 7.0.5
- 7.0.4
- 7.0.3
- 7.0.2
- 7.0.1
- 7.0.0
- 5.x-dev
- 5.0.2
- 5.0.1
- 5.0.0
- v4.1.4
- v4.1.3
- v4.1.2
- v4.1.1
- v4.1.0
- v4.0.9
- v4.0.8
- v4.0.7
- v4.0.6
- v4.0.5
- v4.0.4
- v4.0.3
- v4.0.2
- v4.0.1
- v4.0.0
- 3.0.2
- 3.0.1
- 3.0.0
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 1.0.1
- 1.0.0
This package is auto-updated.
Last update: 2023-01-30 22:11:09 UTC
README
Amazon MWS for Laravel
============
计划迁移到新的 Selling Partner API?请查看我们的 PHP SDK for Amazon's Selling Partner API,以及我们的 Laravel 包装器。
Laravel 包,用于连接到 Amazon 的商家网络服务(MWS)。
如果使用 Laravel 6 或更低版本,请使用版本 5.0。在 Laravel 7 上,请使用版本 7.0+。
这不是 Amazon Web Services(AWS)- 云计算服务。
安装
使用 composer require keithbrink/amazon-mws-laravel
安装包。
对于 Laravel 5.5 及以上版本,包将自动被发现。对于其他版本,可以将 KeithBrink\AmazonMws\MwsServiceProvider
添加到您的 config/app.php
文件中。
运行 php artisan vendor:publish --provider="KeithBrink\AmazonMws\MwsServiceProvider" --tag="config"
将 amazon-mws.php
配置文件添加到您的配置目录。
使用
使用对象的一般工作流程如下
- 为需要执行的任务创建一个对象。
- 使用 set____ 方法加载参数,具体取决于对象。
- 向 Amazon 提交请求。通常用于此的操作的方法名为 fetch____ 或 submit____,并且没有参数。
- 使用 get____ 方法引用返回的数据,无论是单个值还是批量。
- 使用内置的日志系统监控库的性能。
请注意,如果您要操作多个 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(); $orders = []; foreach($amz->getList() as $order) { $orders = $order->getData(); } return $orders; }
此示例显示了一个用于将之前创建的 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/sonnenglas/amazon-mws-laravel
它又从以下地址分支出来:https://github.com/creacoon/amazon-mws-laravel
它又从以下地址分支出来:https://github.com/CPIGroup/phpAmazonMWS
该软件包的原始创建者。