josalba / amazon-mws
用于与Amazon MWS交互的库
0.2.5
2021-09-10 23:22 UTC
Requires
- php: >= 8.0
- ext-simplexml: *
- ext-zlib: *
- guzzlehttp/guzzle: ^7.3
- league/csv: ^9.0
- spatie/array-to-xml: ^2.1
Requires (Dev)
- phpunit/phpunit: ^9.5.9
- dev-master
- 0.2.5
- 0.2.4
- 0.2.3
- 0.2.2
- 0.2.1
- 0.2.0
- 0.1.27
- 0.1.26
- 0.1.25
- 0.1.24
- 0.1.23
- 0.1.22
- 0.1.21
- 0.1.20
- 0.1.19
- 0.1.18
- 0.1.17
- 0.1.16
- 0.1.15
- 0.1.14
- 0.1.13
- 0.1.12
- 0.1.11
- 0.1.10
- 0.1.9
- 0.1.8
- 0.1.7
- 0.1.6
- 0.1.5
- 0.1.4
- 0.1.3
- 0.1.2
- 0.1.1
- 0.1.0
- 0.0.27
- 0.0.26
- 0.0.25
- 0.0.24
- 0.0.23
- 0.0.22
- 0.0.21
- 0.0.20
- 0.0.19
- 0.0.18
- 0.0.17
- 0.0.16
- 0.0.15
- 0.0.14
- 0.0.13
- 0.0.12
- 0.0.11
- 0.0.10
- 0.0.9
- 0.0.8
- 0.0.7
- 0.0.6
- 0.0.5
- 0.0.4
- 0.0.3
- 0.0.2
- 0.0.1
- dev-etiquetas
- dev-readme
- dev-composer
- dev-endpoint
- dev-tracking
This package is not auto-updated.
Last update: 2024-10-01 04:38:31 UTC
README
与被称为MWS的供应商的Amazon API交互。此分支的更新允许从其他市场获取数据,更新跟踪,验证发货代理和购买发货标签。
安装
$ composer require josalba/amazon-mws
启动客户端
require_once 'vendor/autoload.php'; $client = new MCS\MWSClient( 'Marketplace_Id', 'Seller_Id', 'Access_Key_ID', 'Secret_Access_Key', 'MWSAuthToken' // Optional. Only use this key if you are a third party user/developer ); $client->validateCredentials();
检索订单
$orders = $client->getOrders(); foreach ($orders as $order) { $items = $client->ListOrderItems($order['AmazonOrderId']); print_r($order); print_r($items); }
检索产品属性
$searchField = 'ASIN'; // Can be GCID, SellerSKU, UPC, EAN, ISBN, or JAN $result = $client->getMatchingProductForId([ '<ASIN1>', '<ASIN2>', '<ASIN3>' ], $searchField); print_r($result);
创建或更新产品
$product = new MCS\MWSProduct(); $product->sku = 'TESTNOTFORSALE'; $product->price = '1000.00'; $product->product_id = 'B0031S9***'; $product->product_id_type = 'ASIN'; $product->condition_type = 'New'; $product->quantity = 10; if ($product->validate()) { // You can also submit an array of MWSProduct objects $result = $client->postProduct($product); } else { $errors = $product->getValidationErrors(); }
更新产品库存
$result = $client->updateStock([ 'sku1' => 20, 'sku2' => 9, ]); print_r($result); $info = $client->getFeedSubmissionResult($result['FeedSubmissionId']); print_r($info);
更新产品库存和延迟
更新产品库存和准备时间
$result = $client->updateStockWithFulfillmentLatency([ ['sku' => 'sku1', 'quantity' => 20, 'latency' => 1], ['sku' => 'sku2', 'quantity' => 20, 'latency' => 1], ]); print_r($result); $info = $client->getFeedSubmissionResult($result['FeedSubmissionId']); print_r($info);
更新产品价格
$result = $client->updatePrice([ 'sku1' => '20.99', 'sku2' => '100.00', ]); print_r($result); $info = $client->getFeedSubmissionResult($result['FeedSubmissionId']); print_r($info);
报告
访问所有报告类型,请访问: http://docs.developer.amazonservices.com
$reportId = $client->requestReport('_GET_MERCHANT_LISTINGS_DATA_'); // Wait a couple of minutes and get it's content $report_content = $client->GetReport($reportId); print_r($report_content);
更新跟踪
更新订单跟踪。
$return = $client->setTracking( "XXX-XXXXXXX-XXXXXXX", //Order id "MRW", //Agency "Standard", //Method "123456231231" //Tracking );
存储标签
将购买时获取的标签保存在文件中。
$return = $client->labelShipmentToFile( '{ReturnCreateShipment}', '{file}' );
可用方法
查看源代码以获取详细参数描述。所有以大写字母开头的方法也在Amazon MWS文档中有记录。
// Returns the current competitive price of a product, based on ASIN. $client->getCompetitivePricingForASIN($asin_array = []); // Returns the feed processing report and the Content-MD5 header. $client->getFeedSubmissionResult($FeedSubmissionId); // Returns pricing information for the lowest-price active offer listings for up to 20 products, based on ASIN. $client->getLowestOfferListingsForASIN($asin_array = [], $ItemCondition = null); // Returns lowest priced offers for a single product, based on ASIN. $client->getLowestPricedOffersForASIN($asin, $ItemCondition = 'New'); // Returns a list of products and their attributes, based on a list of ASIN, GCID, SellerSKU, UPC, EAN, ISBN, and JAN values. $client->getMatchingProductForId($asin_array, $type = 'ASIN'); // Returns a list of products and their attributes, based on an open text based query $client->listMatchingProducts($query, $query_context_id = null); // Returns pricing information for your own offer listings, based on ASIN. $client->getMyPriceForASIN($asin_array = [], $ItemCondition = null); // Returns pricing information for your own offer listings, based on SKU. $client->getMyPriceForSKU($sku_array = [], $ItemCondition = null); // Returns an order based on the AmazonOrderId values that you specify. $client->getOrder($AmazonOrderId); // Returns the parent product categories that a product belongs to, based on ASIN. $client->getProductCategoriesForASIN($ASIN); // Returns the parent product categories that a product belongs to, based on SellerSKU. $client->getProductCategoriesForSKU($SellerSKU); // Get a report's content $client->getReport($ReportId); // Returns a list of reports that were created in the previous 90 days. $client->getReportList($ReportTypeList = []); // Get a report's processing status $client->getReportRequestStatus($ReportId); // Get a list's inventory for Amazon's fulfillment $client->listInventorySupply($sku_array = []); // Returns a list of marketplaces that the seller submitting the request can sell in, and a list of participations that include seller-specific information in that marketplace $client->listMarketplaceParticipations(); // Returns order items based on the AmazonOrderId that you specify. $client->listOrderItems($AmazonOrderId); // Returns orders created or updated during a time frame that you specify. $client->listOrders($from, $allMarketplaces = false, $states = ['Unshipped', 'PartiallyShipped'], $FulfillmentChannel = 'MFN'); // Returns your active recommendations for a specific category or for all categories for a specific marketplace. $client->listRecommendations($RecommendationCategory = null); // Creates a report request and submits the request to Amazon MWS. $client->requestReport($report, $StartDate = null, $EndDate = null); // Uploads a feed for processing by Amazon MWS. $client->submitFeed($FeedType, $feedContent, $debug = false); // Call this method to get the raw feed instead of sending it $client->debugNextFeed(); // Post to create or update a product (_POST_FLAT_FILE_LISTINGS_DATA_) $client->postProduct($MWSProduct); // Update a product's price $client->updatePrice($array); // Update a product's stock quantity $client->updateStock($array); // A method to quickly check if the supplied credentials are valid $client->validateCredentials();