SubmitFeed上的Amazon Merchant Web Services InputDataError

时间:2013-12-20 12:18:06

标签: php xml curl amazon-mws

我正在使用亚马逊MWS API并尝试使用SubmitFeed更新我的库存库存水平,但是,它始终返回InputDataError,没有进一步的信息。我已经联系了亚马逊,了解我为什么会收到此错误的详细信息,他们告诉我这是一个解析错误,并向我发送了最新的XSD来检查我的XML,但我看不出XML的任何问题。我发送的XML是:

<?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>MY_MERCHANT_TOKEN</MerchantIdentifier>
  </Header>
  <MessageType>Inventory</MessageType>
  <Message>
    <MessageID>1</MessageID>
    <OperationType>Update</OperationType>
    <Inventory>
      <SKU>2360</SKU>
      <Quantity>3</Quantity>
      <FullfillmentLatency>1</FullfillmentLatency>
    </Inventory>
  </Message>
</AmazonEnvelope>

我正在使用phps cURL构建帖子以发送请求,如下所示:

function submitFeed($xmldata, $request)
{
  $request['Signature']=$this->_signParameters($request,$this->_awsSecretAccessKey);
  $url_with_fields="https://mws.amazonservices.co.uk?".$this->_getParametersAsString($request);
  $md5=md5($xmldata);

  $ch = curl_init();               
  curl_setopt($ch, CURLOPT_HTTPHEADER, array(
      'Content-Type: text/xml',                        
      'Content-MD5: '. $md5,
      'Transfer-Encoding: chunked'
  ));

  curl_setopt($ch, CURLOPT_URL,$url_with_fields);
  curl_setopt($ch, CURLINFO_HEADER_OUT, true);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_VERBOSE, true);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
  curl_setopt($ch, CURLOPT_PORT , 443);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
  curl_setopt($ch, CURLOPT_POSTFIELDS, $xmldata); 


  //execute post
  $result = curl_exec($ch);


  print_r($result);

  //close connection
  curl_close($ch);
}

我对cUrl没有经验,我想知道我在这里有什么东西不知道吗?

2 个答案:

答案 0 :(得分:0)

尝试将<FullfillmentLatency>1</FullfillmentLatency>替换为<FulfillmentLatency>1</FulfillmentLatency>

答案 1 :(得分:0)

你是否使用便笺簿检查xml。我确信xml存在问题。 库存XSD有一个序列跟随它来创建xml并在scrathpad中测试。