项目作者: sergo920

项目描述 :
Simple Amazon MWS PHP Client
高级语言: PHP
项目地址: git://github.com/sergo920/amazon-mws-client.git
创建时间: 2020-04-12T12:15:04Z
项目社区:https://github.com/sergo920/amazon-mws-client

开源协议:

下载


Amazon Marketplace Webservices

Latest Stable Version Latest Unstable Version License Total Downloads

Interaction with the Amazon Api for vendors called MWS

Initiate the client

  1. require_once 'vendor/autoload.php';
  2. $client = new MCS\MWSClient([
  3. 'Marketplace_Id' => '',
  4. 'Seller_Id' => '',
  5. 'Access_Key_ID' => '',
  6. 'Secret_Access_Key' => '',
  7. 'MWSAuthToken' => '' // Optional. Only use this key if you are a third party user/developer
  8. ]);
  9. // Optionally check if the supplied credentials are valid
  10. if ($client->validateCredentials()) {
  11. // Credentials are valid
  12. } else {
  13. // Credentials are not valid
  14. }

Get orders

  1. $fromDate = new DateTime('2016-01-01');
  2. $orders = $client->ListOrders($fromDate);
  3. foreach ($orders as $order) {
  4. $items = $client->ListOrderItems($order['AmazonOrderId']);
  5. print_r($order);
  6. print_r($items);
  7. }

Get product attributes

  1. $searchField = 'ASIN'; // Can be GCID, SellerSKU, UPC, EAN, ISBN, or JAN
  2. $result = $client->GetMatchingProductForId([
  3. '<ASIN1>', '<ASIN2>', '<ASIN3>'
  4. ], $searchField);
  5. print_r($result);

Create or update a product

  1. $product = new MCS\MWSProduct();
  2. $product->sku = 'TESTNOTFORSALE';
  3. $product->price = '1000.00';
  4. $product->product_id = 'B0031S9***';
  5. $product->product_id_type = 'ASIN';
  6. $product->condition_type = 'New';
  7. $product->quantity = 10;
  8. if ($product->validate()) {
  9. // You can also submit an array of MWSProduct objects
  10. $result = $client->postProduct($product);
  11. } else {
  12. $errors = $product->getValidationErrors();
  13. }

Update product stock

  1. $result = $client->updateStock([
  2. 'sku1' => 20,
  3. 'sku2' => 9,
  4. ]);
  5. print_r($result);
  6. $info = $client->GetFeedSubmissionResult($result['FeedSubmissionId']);
  7. print_r($info);

Update product stock with fulfillment latency specified

  1. $result = $client->updateStockWithFulfillmentLatency([
  2. ['sku' => 'sku1', 'quantity' => 20, 'latency' => 1],
  3. ['sku' => 'sku2', 'quantity' => 20, 'latency' => 1],
  4. ]);
  5. print_r($result);
  6. $info = $client->GetFeedSubmissionResult($result['FeedSubmissionId']);
  7. print_r($info);

Update product pricing

  1. $result = $client->updatePrice([
  2. 'sku1' => '20.99',
  3. 'sku2' => '100.00',
  4. ]);
  5. print_r($result);
  6. $info = $client->GetFeedSubmissionResult($result['FeedSubmissionId']);
  7. print_r($info);

Reports

For all report types, visit: http://docs.developer.amazonservices.com

  1. $reportId = $client->RequestReport('_GET_MERCHANT_LISTINGS_DATA_');
  2. // Wait a couple of minutes and get it's content
  3. $report_content = $client->GetReport($reportId);
  4. print_r($report_content);

Available methods

View source for detailed argument description.
All methods starting with an uppercase character are also documented in the Amazon MWS documentation

  1. // Returns the current competitive price of a product, based on ASIN.
  2. $client->GetCompetitivePricingForASIN($asin_array = []);
  3. // Returns the feed processing report and the Content-MD5 header.
  4. $client->GetFeedSubmissionResult($FeedSubmissionId);
  5. // Returns pricing information for the lowest-price active offer listings for up to 20 products, based on ASIN.
  6. $client->GetLowestOfferListingsForASIN($asin_array = [], $ItemCondition = null);
  7. // Returns lowest priced offers for a single product, based on ASIN.
  8. $client->GetLowestPricedOffersForASIN($asin, $ItemCondition = 'New');
  9. // Returns a list of products and their attributes, based on a list of ASIN, GCID, SellerSKU, UPC, EAN, ISBN, and JAN values.
  10. $client->GetMatchingProductForId($asin_array, $type = 'ASIN');
  11. // Returns a list of products and their attributes, based on an open text based query
  12. $client->ListMatchingProducts($query, $query_context_id = null);
  13. // Returns pricing information for your own offer listings, based on ASIN.
  14. $client->GetMyPriceForASIN($asin_array = [], $ItemCondition = null);
  15. // Returns pricing information for your own offer listings, based on SKU.
  16. $client->GetMyPriceForSKU($sku_array = [], $ItemCondition = null);
  17. // Returns an order based on the AmazonOrderId values that you specify.
  18. $client->GetOrder($AmazonOrderId);
  19. // Returns the parent product categories that a product belongs to, based on ASIN.
  20. $client->GetProductCategoriesForASIN($ASIN);
  21. // Returns the parent product categories that a product belongs to, based on SellerSKU.
  22. $client->GetProductCategoriesForSKU($SellerSKU);
  23. // Get a report's content
  24. $client->GetReport($ReportId);
  25. // Returns a list of reports that were created in the previous 90 days.
  26. $client->GetReportList($ReportTypeList = []);
  27. // Get a report's processing status
  28. $client->GetReportRequestStatus($ReportId);
  29. // Get a list's inventory for Amazon's fulfillment
  30. $client->ListInventorySupply($sku_array = []);
  31. // 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
  32. $client->ListMarketplaceParticipations();
  33. // Returns order items based on the AmazonOrderId that you specify.
  34. $client->ListOrderItems($AmazonOrderId);
  35. // Returns orders created or updated during a time frame that you specify.
  36. $client->ListOrders($from, $allMarketplaces = false, $states = ['Unshipped', 'PartiallyShipped'], $FulfillmentChannel = 'MFN');
  37. // Returns your active recommendations for a specific category or for all categories for a specific marketplace.
  38. $client->ListRecommendations($RecommendationCategory = null);
  39. // Creates a report request and submits the request to Amazon MWS.
  40. $client->RequestReport($report, $StartDate = null, $EndDate = null);
  41. // Uploads a feed for processing by Amazon MWS.
  42. $client->SubmitFeed($FeedType, $feedContent, $debug = false);
  43. // Call this method to get the raw feed instead of sending it
  44. $client->debugNextFeed();
  45. // Post to create or update a product (_POST_FLAT_FILE_LISTINGS_DATA_)
  46. $client->postProduct($MWSProduct);
  47. // Update a product's price
  48. $client->updatePrice($array);
  49. // Update a product's stock quantity
  50. $client->updateStock($array);
  51. // A method to quickly check if the supplied credentials are valid
  52. $client->validateCredentials();