astgroup / laravel-amazon-mws
一个用于设置和使用Laravel 5.*中的MWS API PHP库的最小服务提供者
0.1.18
2018-07-04 10:55 UTC
Requires
- laravel/framework: 5.6.*
This package is not auto-updated.
Last update: 2024-09-19 13:42:54 UTC
README
一个用于设置和使用Laravel 5.*中的Amazon MWS API PHP库的最小服务提供者
从https://github.com/CPIGroup/phpAmazonMWS 分支而来(基于1.4.2)
版本:0.1.16
工作原理 - 使用示例
use LaravelAmazonMws\AmazonOrderList;
$amz = new AmazonOrderList($store); // Store array $amz->setLimits('Modified', "- 5000 hours"); $amz->setFulfillmentChannelFilter("AFN"); //Amazon-fulfilled orders $amz->setOrderStatusFilter( array("Shipped") ); $amz->setUseToken(); //Amazon sends orders 100 at a time, but we want them all $amz->fetchOrders(); $amz->getList();
以下是如何将这些组件整合在一起。
设置
步骤1:将依赖项添加到composer.json
将以下内容添加到Laravel文件夹中的composer.json文件中。注意:添加此依赖项将自动设置 "anlutro/l4-settings"。
"require": { "astgroup/laravel-amazon-mws": "0.*", }
步骤3:从命令行运行
php artisan vendor:publish
这将发布LaravelSettings配置文件到配置目录,这将让您控制使用哪种存储引擎以及一些特定存储设置。
步骤4:将设置添加到MwsServiceProvider.php文件的'boot'方法中的LaravelSettings设置外观,如下所示
//Set up the MWS configutation as defined in the LaravelSettings Object by app. Setting::set("storeName","mystore"); // This will be the key to store the configuration, you pass this as an option to objects you instanstiate with setstore() Setting::set("authToken",""); //Mws Auth Token - For third party users. Setting::set("merchantId",""); //Seller ID Setting::set("marketplaceId",""); //Marketplace ID Setting::set("keyId",""); //Key ID Setting::set("secretKey",""); //Secret Key Setting::set("amazonServiceUrl",""); // Set to your relevant URL if different from default Setting::set("muteLog","false"); //To log requests, make it true on production to stop logging.
您可以在您的应用程序中引用它们并运行Mws API方法,如以下示例所示 - 确保在初始化对象时指定在'boot'方法中设置的'storename',如下所示
use Mws\Laravel\AmazonOrderList;
$amz = new AmazonOrderList(Setting::get('storeName')); //Store name matches the array key in the settings $amz->setLimits('Modified', "- 5000 hours"); $amz->setFulfillmentChannelFilter("AFN"); //Amazon-fulfilled orders $amz->setOrderStatusFilter( array("Shipped") ); $amz->setUseToken(); //Amazon sends orders 100 at a time, but we want them all $amz->fetchOrders(); $amz->getList();
使用设置外观允许您随时更改设置,或者对于多个用户,在需要执行API调用的任何时候替换设置。例如,登录用户。
大功告成!