我使用亚马逊MWS的库存数量更新Feed出现问题。我的Feed已提交并处理,但是我收到错误,但是如果我通过暂存器提交相同的XML,则会接受并处理库存更新。
(商家ID故意出演)
以下提交和回复:
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>************</MerchantIdentifier>
</Header>
<MessageType>Inventory</MessageType>
<Message>
<MessageID>1</MessageID>
<OperationType>Update</OperationType>
<Inventory>
<SKU>BUS999904</SKU>
<Quantity>269</Quantity>
</Inventory>
</Message>
<Message>
<MessageID>2</MessageID>
<OperationType>Update</OperationType>
<Inventory>
<SKU>PROBS-HO-01</SKU>
<Quantity>137</Quantity>
</Inventory>
</Message>
回复:
<?xml version="1.0" encoding="UTF-8"?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.02</DocumentVersion>
<MerchantIdentifier>M_ONTRACKSCO_1106147</MerchantIdentifier>
</Header>
<MessageType>ProcessingReport</MessageType>
<Message>
<MessageID>1</MessageID>
<ProcessingReport>
<DocumentTransactionID>54774016520</DocumentTransactionID>
<StatusCode>Complete</StatusCode>
<ProcessingSummary>
<MessagesProcessed>2</MessagesProcessed>
<MessagesSuccessful>0</MessagesSuccessful>
<MessagesWithError>2</MessagesWithError>
<MessagesWithWarning>0</MessagesWithWarning>
</ProcessingSummary>
<Result>
<MessageID>1</MessageID>
<ResultCode>Error</ResultCode>
<ResultMessageCode>25</ResultMessageCode>
<ResultDescription>We are unable to process the XML feed because one or more items are invalid. Please re-submit the feed. </ResultDescription>
</Result>
<Result>
<MessageID>2</MessageID>
<ResultCode>Error</ResultCode>
<ResultMessageCode>25</ResultMessageCode>
<ResultDescription>We are unable to process the XML feed because one or more items are invalid. Please re-submit the feed.</ResultDescription>
</Result>
</ProcessingReport>
</Message>
任何人都可以给予任何帮助,或者有效的股票更新供稿的指针/示例将是最受欢迎的。
感谢。
答案 0 :(得分:1)
我终于解决了 - 我的帖子里有不正确的Feed类型。它应该已设置为_POST_INVENTORY_AVAILABILITY_DATA _。
答案 1 :(得分:0)
您的XML似乎在Feed末尾缺少</AmazonEnvelope>
,但在此处粘贴它可能很容易。一旦我添加了它,我就可以根据我的XSD副本验证您的XML。除此之外,我的广告资源Feed仅在一个方面有所不同:我在每个<FulfillmentLatency>1</FulfillmentLatency>
之后都有一个额外的Quanitity
,根据XSD,这不是强制性的。
答案 2 :(得分:0)
亚马逊MWS更新库存库存样本代码:
<?php
/**********************************************************
* Update inventory stock through amazon mws api
*
***********************************************************/
$sku1 = '10101-AM';
$quantity1 = '9';
$leadTimeToShip1 = '7';
//amazon mws credentials
$amazonSellerId = 'xxxxxx';
$amazonMWSAuthToken = 'xxxxxx';
$amazonAWSAccessKeyId = 'xxxxxx';
$amazonSecretKey = 'xxxxxx';
$amazonMarketPlaceId = 'xxxxxx';
$param = array();
$param['AWSAccessKeyId'] = $amazonAWSAccessKeyId;
$param['Action'] = 'SubmitFeed';
$param['Merchant'] = $amazonSellerId;
$param['MWSAuthToken'] = $amazonMWSAuthToken;
$param['FeedType'] = '_POST_INVENTORY_AVAILABILITY_DATA_';
$param['SignatureMethod'] = 'HmacSHA256';
$param['SignatureVersion'] = '2';
$param['Timestamp'] = gmdate("Y-m-d\TH:i:s.\\0\\0\\0\\Z", time());
$param['Version'] = '2009-01-01';
$param['MarketplaceIdList.Id.1'] = $amazonMarketPlaceId;
$param['PurgeAndReplace'] = 'false';
$secret = $amazonSecretKey;
$url = array();
foreach ($param as $key => $val) {
$key = str_replace("%7E", "~", rawurlencode($key));
$val = str_replace("%7E", "~", rawurlencode($val));
$url[] = "{$key}={$val}";
}
$amazon_feed = '<?xml version="1.0" encoding="utf-8"?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>'.$amazonSellerId.'</MerchantIdentifier>
</Header>
<MessageType>Inventory</MessageType>
<Message>
<MessageID>1</MessageID>
<OperationType>Update</OperationType>
<Inventory>
<SKU>'.$sku1.'</SKU>
<Quantity>'.$quantity1.'</Quantity>
<FulfillmentLatency>'.$leadTimeToShip1.'</FulfillmentLatency>
</Inventory>
</Message>
</AmazonEnvelope>';
//echo $amazon_feed;exit;
sort($url);
$arr = implode('&', $url);
$sign = 'POST' . "\n";
$sign .= 'mws.amazonservices.com' . "\n";
$sign .= '/Feeds/'.$param['Version'].'' . "\n";
$sign .= $arr;
$signature = hash_hmac("sha256", $sign, $secret, true);
$httpHeader = array();
$httpHeader[] = 'Transfer-Encoding: chunked';
$httpHeader[] = 'Content-Type: application/xml';
$httpHeader[] = 'Content-MD5: ' . base64_encode(md5($amazon_feed, true));
//$httpHeader[] = 'x-amazon-user-agent: MyScriptName/1.0';
$httpHeader[] = 'Expect:';
$httpHeader[] = 'Accept:';
$signature = urlencode(base64_encode($signature));
$link = "https://mws.amazonservices.com/Feeds/".$param['Version']."?";
$link .= $arr . "&Signature=" . $signature;
$ch = curl_init($link);
curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeader);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $amazon_feed);
$response = curl_exec($ch);
$info = curl_getinfo($ch);
$errors=curl_error($ch);
curl_close($ch);
echo '<pre>';
print_r($response); //xml response
?>