亚马逊MWS API: - 如何使用PHP将xml产品Feed上传到_POST_PRODUCT_DATA_

时间:2015-04-19 00:33:15

标签: xml api amazon-web-services amazon amazon-mws

我遇到了亚马逊MWS API 的问题 出于某种原因,我继续收到此错误消息

“XML在第-1行解析致命错误,第-1列:文件过早结束。文件过早结束。”

我已经尝试了很多教程,示例,文档,sdks和各种各样的。

一切都在回复同样的信息。

以下是我尝试通过xml api服务提交给amazon的xml文件示例

有人可以向我展示一些经过测试和运行的代码,以便使用 PHP 来制作此产品或任何产品吗?

<?xml version="1.0" ?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
    <DocumentVersion>1.01</DocumentVersion>
    <MerchantIdentifier>xxxxx</MerchantIdentifier>
</Header>
<MessageType>Product</MessageType>
<PurgeAndReplace>true</PurgeAndReplace>
<Message>
    <MessageID>1</MessageID>
    <OperationType>Update</OperationType>
    <Product>
        <SKU>1Z-500ABR-FLAT</SKU>
        <ProductTaxCode>A_GEN_TAX</ProductTaxCode>
        <LaunchDate>2005-07-26T00:00:01</LaunchDate>
        <DescriptionData>
            <Title>Lyric 500 tc Queen Flat Sheet, Ivory</Title>
            <Brand>Peacock Alley</Brand>
            <Description>Lyric sheeting by Peacock Alley is t
                he epitome of simple and classic elegance. The flat
                sheets
                and pillowcases feature a double row of hemstitchin
                g. The fitted sheets fit mattresses up to 21 inches
                deep.
                The sheets are shown at left with tone on tone mono
                gramming, please call for monogramming details and
                prices.
                Please note, gift wrapping and overnight shipping a
                re not available for this style.</Description>
            <BulletPoint>made in Italy</BulletPoint>
            <BulletPoint>500 thread count</BulletPoint>
            <BulletPoint>plain weave (percale)</BulletPoint>
            <BulletPoint>100% Egyptian cotton</BulletPoint>
            <Manufacturer>Peacock Alley</Manufacturer>
            <SearchTerms>bedding</SearchTerms>
            <SearchTerms>Sheets</SearchTerms>
            <ItemType>flat-sheets</ItemType>
            <IsGiftWrapAvailable>false</IsGiftWrapAvailable>
            <IsGiftMessageAvailable>false</IsGiftMessageAvailable>
            <RecommendedBrowseNode>60583031</RecommendedBrowseNode>
            <RecommendedBrowseNode>60576021</RecommendedBrowseNode>
        </DescriptionData>
        <ProductData>
            <Home>
                <Parentage>variation-parent</Parentage>
                <VariationData>
                    <VariationTheme>Size-Color</VariationTheme>
                </VariationData>
                <Material>cotton</Material>
                <ThreadCount>500</ThreadCount>
            </Home>
        </ProductData>
    </Product>
</Message>
<Message>

1 个答案:

答案 0 :(得分:1)

您的XML无效。您需要将最后一行<Message>替换为</AmazonEnvelope>,以使其成为有效的XML文档。

您还需要更改<Home>元素的结构,以便使用亚马逊的XSD验证(我假设FurnitureAndDecor是正确的产品类型):

<Home>
    <ProductType>
        <FurnitureAndDecor>
            <Material>cotton</Material>
            <ThreadCount>500</ThreadCount>
            <VariationData>
                <VariationTheme>Size-Color</VariationTheme>
            </VariationData>
        </FurnitureAndDecor>
    </ProductType>
    <Parentage>variation-parent</Parentage>
</Home>