繁体   English   中英

亚马逊MWS API上的GetMyPriceForASIN无法正常工作

[英]GetMyPriceForASIN on Amazon MWS API not working

我正在Amazon MWS API for PHP上测试示例API。 当我运行GetMyPriceForASIN示例中的代码时,它甚至不返回任何响应,即使是错误响应。

$ret = 'ASINList.ASIN.0.=000001ASS&ASINList.ASIN.1.=B00002YHY&ASINList.ASIN.2.=B01112Z4VW';
$request = new MarketplaceWebServiceProducts_Model_GetMyPriceForASINRequest();
$request->setSellerId(MERCHANT_ID);
$request->setASINList($ret);
invokeGetMyPriceForASIN($service, $request);


function invokeGetMyPriceForASIN(MarketplaceWebServiceProducts_Interface $service, $request){
try {
$response = $service->GetMyPriceForASIN($request);
$dom1 = new DOMDocument();
$dom1->loadXML($response->toXML());
$dom1->preserveWhiteSpace = false;
$dom1->formatOutput = true;
echo $dom1->saveXML(); 
} catch (MarketplaceWebServiceProducts_Exception $ex1) {
    echo("Caught Exception: " . $ex1->getMessage() . "\n");
    echo("Response Status Code: " . $ex->getStatusCode() . "\n");
    echo("Error Code: " . $ex1->getErrorCode() . "\n");
    echo("Error Type: " . $ex1->getErrorType() . "\n");
    echo("Request ID: " . $ex1->getRequestId() . "\n");
    echo("XML: " . $ex1->getXML() . "\n");
    echo("ResponseHeaderMetadata: " . $ex1->getResponseHeaderMetadata() . "\n");
}
} 

当我尝试自己调试它时,我一直陷于困境,直到这组代码

public function getMyPriceForASIN($request){    
if (!($request instanceof MarketplaceWebServiceProducts_Model_GetMyPriceForASINRequest)) {
require_once (dirname(__FILE__) . '/Model/GetMyPriceForASINRequest.php');
$request = new MarketplaceWebServiceProducts_Model_GetMyPriceForASINRequest($request);
}

    $parameters = $request->toQueryParameterArray();
    $parameters['Action'] = 'GetMyPriceForASIN';
    $httpResponse = $this->_invoke($parameters);

    require_once (dirname(__FILE__) . '/Model/GetMyPriceForASINResponse.php');
    $response = MarketplaceWebServiceProducts_Model_GetMyPriceForASINResponse::fromXML($httpResponse['ResponseBody']);
    $response->setResponseHeaderMetadata($httpResponse['ResponseHeaderMetadata']);
    return $response;
}

在此代码上,我遇到了一个错误

$parameters = $request->toQueryParameterArray();

它不返回任何数组,我不知道在哪里可以找到函数。 我也想知道可能是我的ASIN列表格式错误,这是格式。

ASINList.ASIN.0.=000001ASS&ASINList.ASIN.1.=B00002YHY&ASINList.ASIN.2.=B01112Z4VW

我终于以我的ASIN列表格式找到了答案,这是错误的。 我使用此代码正确格式化了我的ASIN列表

$asin_list = new MarketplaceWebServiceProducts_Model_ASINListType();
$ret = $asin_list->setASIN($xml_arr);

我认为您需要在$request->setASINList($ret);之前执行此操作$request->setASINList($ret);

require_once "MarketplaceWebServiceProducts_Model_GetMyPriceForASINRequest";
$asin_list = new MarketplaceWebServiceProducts_Model_ASINListType();
$asin_list->setASIN($asins_array);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM