使用亚马逊MWS时,我的Feed应该是什么样子?

时间:2015-02-18 20:09:36

标签: php xml amazon-web-services xsd amazon-mws

我尝试使用MWS实现内部使用基于php的上传产品到我的亚马逊市场的方式。

我已经对这些示例进行了琐事,并认为我在正确的轨道上给出了成功的消息和FeedSubmissionID,但事实并非如此,MWS告诉您,您已经成功完成了SubmitFeed虽然你真的没有。

我的问题与我尝试更新广告资源时{1}}变量的确切含义有关​​。基于亚马逊MWS找到here

代码

这是$feed的精简版 我的AWS_ACCESS_etc ..位于我的.config.inc.php中,它一开始就包含一次。几乎可以肯定这一切都很好,因为我得到了成功的回应。

SubmitFeedSample.php

所以我的$ feed变量就是我所讨论的那个。我在目录中有amzn-envelope.xsd和其他.xsd文件。我做错了什么?

修改

我发现解决方案实际上是我的include_once ('.config.inc.php'); $serviceUrl = "https://mws.amazonservices.com"; $config = array ( 'ServiceURL' => $serviceUrl, 'ProxyHost' => null, 'ProxyPort' => -1, 'MaxErrorRetry' => 3, ); $service = new MarketplaceWebService_Client( AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, $config, APPLICATION_NAME, APPLICATION_VERSION); $feed = ' <?xml version="1.0" ?> <AmazonEnvelope xsi:noNamespaceSchemaLocation="amzn-envelope.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Header> <DocumentVersion>1.01</DocumentVersion> <MerchantIdentifier>A2EUQ1WTGCTBG2</MerchantIdentifier> </Header> <MessageType>Inventory</MessageType> <Message> <MessageID>1</MessageID> <OperationType>Update</OperationType> <Inventory> <SKU>424271</SKU> <Quantity>8</Quantity> </Inventory> </Message> </AmazonEnvelope> '; $marketplaceIdArray = array("Id" => array('ATVPDKIKX0DER')); $feedHandle = @fopen('php://temp', 'rw+'); fwrite($feedHandle, $feed); rewind($feedHandle); $parameters = array ( 'Merchant' => MERCHANT_ID, 'MarketplaceIdList' => $marketplaceIdArray, 'FeedType' => '_POST_INVENTORY_AVAILABILITY_DATA_', 'FeedContent' => $feedHandle, 'PurgeAndReplace' => false, 'ContentMd5' => base64_encode(md5(stream_get_contents($feedHandle), true)), //'MWSAuthToken' => '<MWS Auth Token>', // Optional ); rewind($feedHandle); $request = new MarketplaceWebService_Model_SubmitFeedRequest($parameters); invokeSubmitFeed($service, $request); @fclose($feedHandle); function invokeSubmitFeed(MarketplaceWebService_Interface $service, $request) { try { $response = $service->submitFeed($request); echo ("Service Response\n"); echo ("=============================================================================\n"); echo(" SubmitFeedResponse\n"); if ($response->isSetSubmitFeedResult()) { echo(" SubmitFeedResult\n"); $submitFeedResult = $response->getSubmitFeedResult(); if ($submitFeedResult->isSetFeedSubmissionInfo()) { echo(" FeedSubmissionInfo\n"); $feedSubmissionInfo = $submitFeedResult->getFeedSubmissionInfo(); if ($feedSubmissionInfo->isSetFeedSubmissionId()) { echo(" FeedSubmissionId\n"); echo(" " . $feedSubmissionInfo->getFeedSubmissionId() . "\n"); } if ($feedSubmissionInfo->isSetFeedType()) { echo(" FeedType\n"); echo(" " . $feedSubmissionInfo->getFeedType() . "\n"); } if ($feedSubmissionInfo->isSetSubmittedDate()) { echo(" SubmittedDate\n"); echo(" " . $feedSubmissionInfo->getSubmittedDate()->format(DATE_FORMAT) . "\n"); } if ($feedSubmissionInfo->isSetFeedProcessingStatus()) { echo(" FeedProcessingStatus\n"); echo(" " . $feedSubmissionInfo->getFeedProcessingStatus() . "\n"); } if ($feedSubmissionInfo->isSetStartedProcessingDate()) { echo(" StartedProcessingDate\n"); echo(" " . $feedSubmissionInfo->getStartedProcessingDate()->format(DATE_FORMAT) . "\n"); } if ($feedSubmissionInfo->isSetCompletedProcessingDate()) { echo(" CompletedProcessingDate\n"); echo(" " . $feedSubmissionInfo->getCompletedProcessingDate()->format(DATE_FORMAT) . "\n"); } } } if ($response->isSetResponseMetadata()) { echo(" ResponseMetadata\n"); $responseMetadata = $response->getResponseMetadata(); if ($responseMetadata->isSetRequestId()) { echo(" RequestId\n"); echo(" " . $responseMetadata->getRequestId() . "\n"); } } echo(" ResponseHeaderMetadata: " . $response->getResponseHeaderMetadata() . "\n"); } catch (MarketplaceWebService_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"); } } 变量,因为我不需要 \&lt; \?xml version =&#34; 1.0&#34; \?&gt; 这是我Feed中的一部分。

1 个答案:

答案 0 :(得分:3)

您的Feed使用Amazon XSD验证,这意味着它在结构上很好,但仍可能包含逻辑错误,例如您的产品列表中没有SKU 424271。要从Amazon获取有关逻辑错误的信息,仅调用SubmitFeed并检查其结果是不够的,因为这只会告诉您订阅源已被接受并放入处理队列中。您还需要等待处理该Feed并检查处理结果。

how to check the processing state and results of MWS feeds

另请注意,您需要发送多个相互依赖的Feed。如果在当前数据之前尚未发送(或未能处理)其他供稿,则供稿很容易失败。

sending multiple dependent MWS feeds to update products