Fetch product from amazon mws using product api

天大地大妈咪最大 提交于 2019-12-08 10:40:31

问题


I have successfully posted product in amazon using amazon MWS Feeds API. Now i want to list those products using the Products API, But im facing some errors. I run GetMatchingProductSample.php.

Caught Exception: Required parameter ASINList not found Response Status Code: 400 Error Code: MissingParameter Error Type: Sender Request ID: 8bb9c8d1-f48c-495c-be86-89492976b4a9 XML: SenderMissingParameterRequired parameter ASINList not found8bb9c8d1-f48c-495c-be86-89492976b4a9 ResponseHeaderMetadata: RequestId: 8bb9c8d1-f48c-495c-be86-89492976b4a9

Code:

<?php
require_once('.config.inc.php');

$serviceUrl = "https://mws-eu.amazonservices.com/Products/2011-10-01";


$config = array (
  'ServiceURL' => $serviceUrl,
  'ProxyHost' => null,
  'ProxyPort' => -1,
  'ProxyUsername' => null,
  'ProxyPassword' => null,
  'MaxErrorRetry' => 3,
);

$service = new MarketplaceWebServiceProducts_Client(
      AWS_ACCESS_KEY_ID,
      AWS_SECRET_ACCESS_KEY,
      APPLICATION_NAME,
      APPLICATION_VERSION,
      $config);
$request = new MarketplaceWebServiceProducts_Model_GetMatchingProductRequest();
$request->setSellerId(MERCHANT_ID);
// object or array of parameters
invokeGetMatchingProduct($service, $request);

function invokeGetMatchingProduct(MarketplaceWebServiceProducts_Interface $service, $request)
{
    try {
      $response = $service->GetMatchingProduct($request);

      echo ("Service Response\n");
      echo ("=============================================================================\n");

      $dom = new DOMDocument();
      $dom->loadXML($response->toXML());
      $dom->preserveWhiteSpace = false;
      $dom->formatOutput = true;
      echo $dom->saveXML();
      echo("ResponseHeaderMetadata: " . $response->getResponseHeaderMetadata() . "\n");

   } catch (MarketplaceWebServiceProducts_Exception $ex) {
      echo("Caught Exception: " . $ex->getMessage() . "\n");
      echo("Response Status Code: " . $ex->getStatusCode() . "\n");
      echo("Error Code: " . $ex->getErrorCode() . "\n");
      echo("Error Type: " . $ex->getErrorType() . "\n");
      echo("Request ID: " . $ex->getRequestId() . "\n");
      echo("XML: " . $ex->getXML() . "\n");
      echo("ResponseHeaderMetadata: " . $ex->getResponseHeaderMetadata() . "\n");
   }
}

回答1:


As it says ASINList not found

You need to add these line of code after below line

$request->setSellerId(MERCHANT_ID);

Code needs to add:

$request->setMarketplaceId($marketplace_id);
$asin_list = new MarketplaceWebServiceProducts_Model_ASINListType();
$asins = array("ASIN1","ASIN2","ASIN3");
$asin_list->setASIN($asins);
$request->setASINList($asin_list);


来源:https://stackoverflow.com/questions/37416063/fetch-product-from-amazon-mws-using-product-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!