dop82210 2016-02-29 19:38
浏览 183
已采纳

Ebay Api - 使用php添加产品

I'm having trouble with the eBay API, I am trying to upload my inventory to my eBay store. I have registered as a developer and read through the tutorials and examples but for some reason this wont work, here is my current XML that is generated through the database.

<?xml version="1.0" encoding="utf-8"?>
<AddItems xmlns="urn:ebay:apis:eBLBaseComponents">
<ErrorLanguage>en_US</ErrorLanguage>
<WarningLevel>High</WarningLevel>
<Item>
<Title>Fun Novelty Routemaster Red Bus Mug</Title>
<Description><p>Fun Novelty Routemaster Red Bus Mug</p><p>If you are looking for a novelty gift thats practical and looks great, then check out our funky kitchen and ceramics range.</p><p>The range is made from dolomite ceramics and finished in a high gloss glaze. Each comes in a decorative gift box to complete the look, plus if its a kitchen item then dolomite is food and microwave safe but cannot be put in the dishwasher.</p></Description>
<PrimaryCategory><CategoryID>14899</CategoryID>
</PrimaryCategory>
<StartPrice>9.99</StartPrice>
<CategoryMappingAllowed>true</CategoryMappingAllowed>
<ConditionID>1000</ConditionID>
<Country>GB</Country>
<Currency>GBP</Currency>
<DispatchTimeMax>3</DispatchTimeMax>
<ListingDuration>Days_30</ListingDuration>
<ListingType>FixedPriceItem</ListingType>
<PaymentMethods>PayPal</PaymentMethods>
<PayPalEmailAddress>info@3cheekymonkeys.co.uk</PayPalEmailAddress>
<PictureDetails><GalleryType>Gallery</GalleryType>
</PictureDetails>
<PostalCode>95125</PostalCode>
<ProductListingDetails><UPC>5055071655654</UPC>
<IncludeStockPhotoURL>true</IncludeStockPhotoURL>
<IncludePrefilledItemInformation>true</IncludePrefilledItemInformation>
<UseFirstProduct>true</UseFirstProduct>
<UseStockPhotoURLAsGallery>true</UseStockPhotoURLAsGallery>
<ReturnSearchResultOnDuplicates>true</ReturnSearchResultOnDuplicates>
</ProductListingDetails>
<Quantity>6</Quantity>
<ReturnPolicy><ReturnsAcceptedOption>ReturnsAccepted</ReturnsAcceptedOption>
<RefundOption>MoneyBack</RefundOption>
<ReturnsWithinOption>Days_14</ReturnsWithinOption>
<Description>If you are not satisfied, return the item for refund.    </Description>
<ShippingCostPaidByOption>Buyer</ShippingCostPaidByOption>
</ReturnPolicy>
<ShippingDetails><ShippingType>Flat</ShippingType>
<ShippingServiceOptions><ShippingServicePriority>1</ShippingServicePriority>
<ShippingService>UK_RoyalMailFirstClassStandard</ShippingService>
<FreeShipping>true</FreeShipping>
<ShippingServiceAdditionalCost>0.00</ShippingServiceAdditionalCost>
</ShippingServiceOptions>
</ShippingDetails>
<Site>UK</Site>
</Item>
<RequesterCredentials>
<eBayAuthToken>AUTHC CODE</eBayAuthToken>
</RequesterCredentials>
<WarningLevel>High</WarningLevel>
</AddItems>

and here is the results from ebay

The AddItem called failed due to the following error(s):
Error: [21843] The job context object is not supported by Action Service Framework. 

My Headers and CURL

    $headers = array(
    'X-EBAY-API-SITEID:'.SITEID,
    'X-EBAY-API-CALL-NAME:AddItem',
    'X-EBAY-API-REQUEST-ENCODING:'.RESPONSE_ENCODING,
    'X-EBAY-API-COMPATIBILITY-LEVEL:' . API_COMPATIBILITY_LEVEL,
    'X-EBAY-API-DEV-NAME:' . API_DEV_NAME,
    'X-EBAY-API-APP-NAME:' . API_APP_NAME,
    'X-EBAY-API-CERT-NAME:' . API_CERT_NAME,
    'Content-Type: text/xml;charset=utf-8'
);

// initialize our curl session
$session  = curl_init(API_URL);

// set our curl options with the XML request
curl_setopt($session, CURLOPT_HTTPHEADER, $headers);
curl_setopt($session, CURLOPT_POST, true);
curl_setopt($session, CURLOPT_POSTFIELDS, $xmlRequest);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);

// execute the curl request
$responseXML = curl_exec($session);

// close the curl session
curl_close($session);

// return the response XML
return $responseXML;

When changing from AddItem to AddFixedPriceItemRequest the error changes to

 Schema XML request error: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize..

When running the example in the API Test Tool it wont work same results, and also when running the Test Tool with the example code provided it works until i copy that sample XML into my file and try and run the program then i get the error messages back?

  • 写回答

2条回答 默认 最新

  • doushi6864 2016-02-29 19:47
    关注

    UPDATE

    The html tags within the description tag breaks the xml. For a workaround you want to enclose your description using CDATA:

    <Description><![CDATA[ <p>Fun Novelty .. put in the dishwasher.</p>]]></Description>
    

    In Detail:

    • Error: [21843] The job context object is not supported by Action Service Framework. seems to be provoked by a mismatch between the header and the xml.

    See here for details: https://stackoverflow.com/a/13791811/2797243

    • Schema XML request error: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize..

    There can be many reasons why you are recieiving this error, but we will focus on just 2 situations:

    1. You may be getting this error because the given root element in your request xml document does not match any Element Declarations in eBay Schema.

    Answer Title: Error 20170 - Schema XML request error Answer Link: https://ebaydts.com/eBayKBDetails?KBid=897

    1. Another common reason is your has HTML or XML reserved characters. For a workaround you want to enclose your description using CDATA.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能