我已阅读this以及其他一些没有帮助的糟糕教程。我爱亚马逊..但我很难使用他们的API并让亚马逊接受“listItem”xml请求。我无法从亚马逊那里得到一个返回串,我不知道为什么。这是我的代码:
$post_string = '<?xml version="1.0" ?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amznenvelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>' . $merchantID . '</MerchantIdentifier>
</Header>
<MessageType>Product</MessageType>
<PurgeAndReplace>true</PurgeAndReplace>
<Message>
<MessageID>' . rand(1,1000) . '</MessageID>
<OperationType>Update</OperationType>
<Product>
<SKU>'. $product->getSKU() .'</SKU>
<ProductTaxCode>A_GEN_TAX</ProductTaxCode>
<LaunchDate>'.date('Y-m-d') . 'T' . date('H:i:sO');'.</LaunchDate>
<DescriptionData>
<Title>'. $product->getName().'</Title>
<Brand>'.$product->getBrand.'</Brand>
<Description>' . $product->getDescription() . '</Description>
<SearchTerms></SearchTerms>
<SearchTerms></SearchTerms>
<ItemType>flat-sheets</ItemType>
<IsGiftWrapAvailable>false</IsGiftWrapAvailable>
<IsGiftMessageAvailable>false</IsGiftMessageAvailable>
</DescriptionData>i
<ProductData>
<Home>
<Parentage>variation-parent</Parentage>
<VariationData>
<VariationTheme>Size-Color</VariationTheme>
</VariationData>
<Material></Material>
<ThreadCount>500</ThreadCount>
</Home>
</ProductData>
</Product>
</Message>
<Message>
</AmazonEnvelope>';
$header = "POST HTTP/1.0 \r\n";
$header .= "Content-type: text/xml \r\n";
$header .= "Content-length: ". strlen($post_string) ."\r\n";
$header .= "Content-transfer-encoding: text \r\n";
$header .= "Connection: close \r\n\r\n";
$header .= $post_string;
// Create a curl instance
$amazon_api = curl_init();
curl_setopt($amazon_api, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($amazon_api, CURLOPT_URL, "https://".$hosti."/");#."?$query_string" );
curl_setopt($amazon_api, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($amazon_api, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($amazon_api, CURLOPT_POST, 1);
curl_setopt($amazon_api, CURLOPT_USERAGENT, 'OutdoorOutlet/1.0 (Language=PHP; Host=www.outdooroutlet.com)');
$returnString = trim(curl_exec($amazon_api));
有关如何以更简单的方式执行此操作的任何建议,或者如果有一些我可以使用的php模块,这将使列表更容易。如果需要更多代码,或者更多地解释我正在做什么,请告诉我。我真的不知道我的下一步应该是什么:(感谢所有的帮助!