首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Ebay Api -使用php添加产品

Ebay Api -使用php添加产品
EN

Stack Overflow用户
提问于 2016-02-29 19:38:13
回答 2查看 943关注 0票数 3

我有问题的eBay API,我试图上传我的库存到我的eBay商店。我已注册为开发人员,并阅读了教程和示例,但由于某些原因,这是我当前通过数据库生成的XML。

代码语言:javascript
复制
<?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>

这是ebay的结果

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

我的头和卷发

代码语言:javascript
复制
    $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;

当从AddItem更改为AddFixedPriceItemRequest时,错误将更改为

代码语言:javascript
复制
 Schema XML request error: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize..

当在API测试工具中运行示例时,它不会工作相同的结果,而且在运行带有示例代码的测试工具时,它也可以工作,直到我将该示例XML复制到我的文件中并尝试运行该程序,然后才能得到错误消息?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-02-29 19:47:22

更新

description标记中的html标记破坏了xml。为了解决这个问题,您需要使用CDATA将您的描述附在一起:

代码语言:javascript
复制
<Description><![CDATA[ <p>Fun Novelty .. put in the dishwasher.</p>]]></Description>

详细

  • Error: [21843] The job context object is not supported by Action Service Framework.似乎是由头和xml之间的不匹配引起的。

详见此处: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..

您收到此错误的原因可能很多,但我们将只关注以下两种情况:

  1. 您可能会收到此错误,因为您的请求xml文档中的给定根元素与eBay架构中的任何元素声明不匹配。

答案标题:错误20170 -架构XML请求错误答案链接:https://ebaydts.com/eBayKBDetails?KBid=897

  1. 另一个常见的原因是您有HTML或XML保留字符。为了解决这个问题,您需要使用CDATA将您的描述附在一起。

票数 1
EN

Stack Overflow用户

发布于 2016-02-29 19:54:55

试着改变:

<AddItems xmlns="urn:ebay:apis:eBLBaseComponents">

<AddItemsRequest xmlns="urn:ebay:apis:eBLBaseComponents">

以及:

</AddItems>

</AddItemsRequest>

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35708117

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档