使用 php 在亚马逊上列出商品?
我已阅读此 以及其他一些没有帮助的蹩脚教程。我喜欢亚马逊..但我很难使用他们的 API 并让亚马逊接受“listItem”xml 请求。我无法从亚马逊返回 returnString,我不知道为什么。这是我的代码:
$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 模块,这将使列表变得更容易。如果需要更多代码,或者需要更多解释我正在做什么,请告诉我。我真的不知道我的下一步应该是什么:( 感谢您的帮助!
I have read this and few other crappy tutorials that didn't help. I love amazon.. but I am having a very hard time using their API and getting amazon to accept a "listItem" xml request. I can't get a returnString back from amazon and I'm not sure why. Here is my Code:
$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));
Any suggestion on how to do this in an easier way or if there is some modules for php that I could use that would make listing easier. If more code is needed, or more of an explanation of what im doing, just let me know. I really don't know what my next step should be :( Thanks for all the help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论