我已使用亚马逊MWS Feeds API
在亚马逊成功发布了产品。现在我想使用Products API列出这些产品,但我面临一些错误。
我运行GetMatchingProductSample.php
。
捕获异常:必需参数未找到ASINList响应状态码:400错误代码:MissingParameter错误类型:发件人请求ID:8bb9c8d1-f48c-495c-be86-89492976b4a9 XML:SenderMissingParameterRequired参数ASINList not found8bb9c8d1-f48c-495c-be86- 89492976b4a9 ResponseHeaderMetadata:RequestId:8bb9c8d1-f48c-495c-be86-89492976b4a9
代码:
<?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");
}
}
答案 0 :(得分:4)
因为它没有找到ASINList
您需要在以下行
之后添加这些代码行$request->setSellerId(MERCHANT_ID);
代码需要添加:
$request->setMarketplaceId($marketplace_id);
$asin_list = new MarketplaceWebServiceProducts_Model_ASINListType();
$asins = array("ASIN1","ASIN2","ASIN3");
$asin_list->setASIN($asins);
$request->setASINList($asin_list);