PHPackages                             binhuang/amazon-publish - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. binhuang/amazon-publish

ActiveLibrary[API Development](/categories/api)

binhuang/amazon-publish
=======================

Library to interface with Amazon MWS

1.01(5y ago)05MITPHPPHP &gt;=7.0

Since Sep 14Pushed 4y ago1 watchersCompare

[ Source](https://github.com/huanghuag/amazon-publish)[ Packagist](https://packagist.org/packages/binhuang/amazon-publish)[ RSS](/packages/binhuang-amazon-publish/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (2)Dependencies (4)Versions (3)Used By (0)

\####这是参考了连接[https://github.com/forecho/amazon-mws的一个项目，里面做了一些适用于自己项目的修改，故自己弄了个git存储](https://github.com/forecho/amazon-mws%E7%9A%84%E4%B8%80%E4%B8%AA%E9%A1%B9%E7%9B%AE%EF%BC%8C%E9%87%8C%E9%9D%A2%E5%81%9A%E4%BA%86%E4%B8%80%E4%BA%9B%E9%80%82%E7%94%A8%E4%BA%8E%E8%87%AA%E5%B7%B1%E9%A1%B9%E7%9B%AE%E7%9A%84%E4%BF%AE%E6%94%B9%EF%BC%8C%E6%95%85%E8%87%AA%E5%B7%B1%E5%BC%84%E4%BA%86%E4%B8%AAgit%E5%AD%98%E5%82%A8)

Amazon Marketplace Webservices
==============================

[](#amazon-marketplace-webservices)

[![Latest Stable Version](https://camo.githubusercontent.com/370f8882791830333695c7d397fd65b171292bf72b05d87144a71db1a3c06f9b/68747470733a2f2f706f7365722e707567782e6f72672f6d63732f616d617a6f6e2d6d77732f762f737461626c65)](https://packagist.org/packages/mcs/amazon-mws)[![Latest Unstable Version](https://camo.githubusercontent.com/14b5c8e0e085d6f96119cc77a45e4cd5d1f9588a5617b16fc37a4acdd62ee9cd/68747470733a2f2f706f7365722e707567782e6f72672f6d63732f616d617a6f6e2d6d77732f762f756e737461626c65)](https://packagist.org/packages/mcs/amazon-mws)[![License](https://camo.githubusercontent.com/9d716115ae81380d1b70936728960034b4c0d9884dd4298139e69b4c7955f592/68747470733a2f2f706f7365722e707567782e6f72672f6d63732f616d617a6f6e2d6d77732f6c6963656e7365)](https://packagist.org/packages/mcs/amazon-mws)[![Total Downloads](https://camo.githubusercontent.com/3e9c9b3af093b87a0a06157d85f36ae45b230e7335e7016662b800887387971c/68747470733a2f2f706f7365722e707567782e6f72672f6d63732f616d617a6f6e2d6d77732f646f776e6c6f616473)](https://packagist.org/packages/mcs/amazon-mws)

Interaction with the Amazon Api for vendors called MWS

### Change your composer.json file

[](#change-your-composerjson-file)

```
"require": {
    // ...
    "mcs/amazon-mws": "*",
    // ...
},
"repositories": [
    {
        "name": "mcs/amazon-mws",
        "type": "git",
        "url": "git@github.com:forecho/amazon-mws.git"
    }
]

```

### Installation:

[](#installation)

```
$ composer require mcs/amazon-mws
```

### Initiate the client

[](#initiate-the-client)

```
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
]);

// Optionally check if the supplied credentials are valid
if ($client->validateCredentials()) {
    // Credentials are valid
} else {
    // Credentials are not valid
}
```

### Get orders

[](#get-orders)

```
$fromDate = new DateTime('2016-01-01');
$orders = $client->ListOrders($fromDate);
foreach ($orders as $order) {
    $items = $client->ListOrderItems($order['AmazonOrderId']);
    print_r($order);
    print_r($items);
}
```

### Get product attributes

[](#get-product-attributes)

```
$searchField = 'ASIN'; // Can be GCID, SellerSKU, UPC, EAN, ISBN, or JAN

$result = $client->GetMatchingProductForId([
    '', '', ''
], $searchField);

print_r($result);
```

### Create or update a marketplace product

[](#create-or-update-a-marketplace-product)

```
public function uploadAmazon(string $productType, Product $product, int $productNode, $otherAttributes = [])
{
    $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
    ]);
    $amazonProducts = [];
    $postItems = [];
    $amazonProduct = new AmazonMarketPlaceProduct();
    if ($product->productSku) {
        $amazonProduct->setSku($product->parent_sku)
            ->setFeedProductType($productType)
            ->setBrand($product->brand)
            ->setTitle($product->title)
            ->setManufacturer($product->manufacturer)
            ->setRecommendedBrowseNodes($productNode)
            ->setParentChild('Parent')
            ->setOtherAttributes(\app\core\helpers\ArrayHelper::clearValue($otherAttributes))
            ->setVariationTheme($product->variation_theme);
        array_push($amazonProducts, $amazonProduct);
        array_push($postItems, $amazonProduct->toArray(false));

        foreach ($product->productSku as $productSku) {
            $retailPrice = $productSku->retail_price ?: 0;
            $salePrice = $productSku->sale_price ?: 0;
            $saleDate = $salePrice ? explode('~', $productSku->sale_date) : [];

            $_amazonProduct = clone $amazonProduct;
            $_amazonProduct->setSku($productSku->product_sku)
                ->setFeedProductType($productType)
                ->setBrand($product->brand)
                ->setTitle($product->title)
                ->setManufacturer($product->manufacturer)
                ->setPrice($retailPrice > 0 ? CurrencyConverter::CNYConverter($currency, $retailPrice) : '')
                ->setSalePrice($salePrice > 0 ? CurrencyConverter::CNYConverter($currency, $salePrice) : '')
                ->setProductId($amazonProductId)
                ->setSizeName($productSku->size ?: '')
                ->setColorName($productSku->color ?: '')
                ->setProductIdType('EAN')
                ->setCurrency($currency)
                ->setConditionType('New')
                ->setWeight($product->weight)
                ->setQuantity($product->quantity)
                ->setParentChild('Child')
                ->setParentSku($parentSku)
                ->setSaleFromDate(count($saleDate) == 2 ? $saleDate[0] : '')
                ->setSaleEndDate(count($saleDate) == 2 ? $saleDate[1] : '')
                ->setVariationTheme($product->variation_theme)
                ->setKeywords($product->search_keyword)
                ->setRecommendedBrowseNodes($productNode)
                ->setBulletPoint($features)
                ->setDescription($product->description)
                ->setOtherAttributes($otherAttributes)
                ->setImage($productSku->images);
            array_push($amazonProducts, $_amazonProduct);
            array_push($postItems, $_amazonProduct->toArray(false));
        }
    } else {
        $retailPrice = $product->price ?: 0;
        $salePrice = $product->sale_price ?: 0;
        $saleDate = $salePrice ? explode('~', $product->sale_date) : [];

        $amazonProduct->setSku($parentSku)
            ->setFeedProductType($productType)
            ->setBrand($product->brand)
            ->setTitle($product->{$titleAttribute})
            ->setManufacturer($product->manufacturer)
            ->setPrice($retailPrice > 0 ? CurrencyConverter::CNYConverter($currency, $retailPrice) : '')
            ->setSalePrice($salePrice > 0 ? CurrencyConverter::CNYConverter($currency, $salePrice) : '')
            ->setProductId($amazonProductId)
            ->setProductIdType('EAN')
            ->setCurrency($currency)
            ->setConditionType('New')
            ->setWeight($product->weight)
            ->setQuantity($product->quantity)
            ->setSaleFromDate(count($saleDate) == 2 ? $saleDate[0] : '')
            ->setSaleEndDate(count($saleDate) == 2 ? $saleDate[1] : '')
            ->setKeywords($product->search_keyword)
            ->setRecommendedBrowseNodes($productNode)
            ->setBulletPoint($features)
            ->setDescription($product->description)
            ->setOtherAttributes($otherAttributes)
            ->setImage($product->images);
        array_push($amazonProducts, $amazonProduct);
        array_push($postItems, $amazonProduct->toArray(false));
    }

    // You can also submit an array of MWSProduct objects
    $feed = $client->postProduct(
        $amazonProducts,
        'fptcustomcustom',
        '2019.0501',
        'SE9NRV9MSUdIVElOR19BTkRfTEFNUFM='
    );
    return $feed;
}
```

### Update product stock

[](#update-product-stock)

```
$result = $client->updateStock([
    'sku1' => 20,
    'sku2' => 9,
]);
print_r($result);

$info = $client->GetFeedSubmissionResult($result['FeedSubmissionId']);
print_r($info);
```

### Update product stock with fulfillment latency specified

[](#update-product-stock-with-fulfillment-latency-specified)

```
$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);
```

### Update product pricing

[](#update-product-pricing)

```
$result = $client->updatePrice([
    'sku1' => '20.99',
    'sku2' => '100.00',
]);
print_r($result);

$info = $client->GetFeedSubmissionResult($result['FeedSubmissionId']);
print_r($info);
```

### Reports

[](#reports)

For all report types, visit: [http://docs.developer.amazonservices.com](http://docs.developer.amazonservices.com/en_US/reports/Reports_ReportType.html#ReportTypeCategories__ListingsReports)

```
$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);
```

### Available methods

[](#available-methods)

View source for detailed argument description. All methods starting with an uppercase character are also documented in the [Amazon MWS documentation](http://docs.developer.amazonservices.com/en_US/dev_guide/index.html)

```
// 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();
```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

2067d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e48c553684fbaf81f8a4db01fa800c69a9f58d6c7478a41c0157341492c9332c?d=identicon)[huanghuang](/maintainers/huanghuang)

---

Top Contributors

[![huanghuag](https://avatars.githubusercontent.com/u/33785106?v=4)](https://github.com/huanghuag "huanghuag (6 commits)")

---

Tags

amazonmws

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/binhuang-amazon-publish/health.svg)

```
[![Health](https://phpackages.com/badges/binhuang-amazon-publish/health.svg)](https://phpackages.com/packages/binhuang-amazon-publish)
```

###  Alternatives

[looxis/laravel-amazon-mws

Simple Amazon MWS API Package for Laravel

3218.7k](/packages/looxis-laravel-amazon-mws)[weengsapp/amazon-mws-client

PHP client for Amazon MWS API

1551.7k](/packages/weengsapp-amazon-mws-client)[thiagomarini/amazon-mws-client

PHP client for Amazon MWS API

151.4k](/packages/thiagomarini-amazon-mws-client)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
