2017-07-28 241 views
0

我试图用ebay Tradding API使用php和CURL在ebay上列出一个项目。易趣交易API错误AddItem服务

XML请求和CURL语法对我来说似乎很好,有人可以指导我还有什么缺失。

我想我错过了标题中的内容。

将不胜感激。

$xml_string = '<?xml version="1.0" encoding="utf-8"?> 
         <AddItemRequest xmlns="urn:ebay:apis:eBLBaseComponents"> 
          <RequesterCredentials> 
          <eBayAuthToken>*Token*</eBayAuthToken> 
          </RequesterCredentials> 
          <ErrorLanguage>en_US</ErrorLanguage> 
          <WarningLevel>High</WarningLevel> 
          <Item> 
          <Title>'.$postdata['item_name'].'</Title> 
          <Description>'.$postdata['external_comments'].'</Description> 
          <PrimaryCategory> 
           <CategoryID>377</CategoryID> 
          </PrimaryCategory> 
          <StartPrice>'.$postdata['ebay_price'].'</StartPrice> 
          <CategoryMappingAllowed>true</CategoryMappingAllowed> 
          <Country>US</Country> 
          <Currency>USD</Currency> 
          <ConditionID>1000</ConditionID> 
          <DispatchTimeMax>3</DispatchTimeMax> 
          <ListingDuration>Days_7</ListingDuration> 
          <ListingType>Chinese</ListingType> 
          <PaymentMethods>PayPal</PaymentMethods> 
          <!--Enter your Paypal email address--> 
          <PayPalEmailAddress>[email protected]</PayPalEmailAddress> 
          <PictureDetails> 
           <PictureURL>http://pics.ebay.com/aw/pics/dot_clear.gif</PictureURL> 
          </PictureDetails> 
          <PostalCode>95125</PostalCode> 
          <Quantity>1</Quantity> 
          <ReturnPolicy> 
           <ReturnsAcceptedOption>ReturnsAccepted</ReturnsAcceptedOption> 
           <RefundOption>MoneyBack</RefundOption> 
           <ReturnsWithinOption>Days_30</ReturnsWithinOption> 
           <Description>If you are not satisfied, return the book for refund.</Description> 
           <ShippingCostPaidByOption>Buyer</ShippingCostPaidByOption> 
          </ReturnPolicy> 
          <ShippingDetails> 
           <ShippingType>Flat</ShippingType> 
           <ShippingServiceOptions> 
           <ShippingServicePriority>1</ShippingServicePriority> 
           <ShippingService>USPSMedia</ShippingService> 
           <ShippingServiceCost>2.50</ShippingServiceCost> 
           </ShippingServiceOptions> 
          </ShippingDetails> 
          <Site>US</Site> 
         </Item> 
         </AddItemRequest>'; 

     $ch = curl_init(); 
     curl_setopt($ch, CURLOPT_URL, "https://api.sandbox.ebay.com/ws/api.dll"); 
     $headers = array(
      'Content-Type: text/xml', 
      'X-EBAY-API-COMPATIBILITY-LEVEL: 967', 
      'X-EBAY-API-DEV-NAME: ', 
      'X-EBAY-API-APP-NAME: ', 
      'X-EBAY-API-CERT-NAME: ', 
      'X-EBAY-API-SITEID: 2', 
      'X-EBAY-API-CALL-NAME: AddItems' 
     ); 

     curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 
     curl_setopt($ch, CURLOPT_POSTFIELDS, "xmlRequest=" . $xml_string); 
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); 
     curl_setopt($ch, CURLOPT_HEADER, FALSE); 
     curl_setopt($ch, CURLOPT_POST, TRUE); 
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 300); 

和响应是:

<?xml version="1.0" encoding="UTF-8"?> 
    <AddItemsResponse xmlns="urn:ebay:apis:eBLBaseComponents"> 
    <Timestamp>2017-07-28T18:48:59.487Z</Timestamp> 
    <Ack>Failure</Ack> 
    <Errors> 
     <ShortMessage>Invalid job context type</ShortMessage> 
     <LongMessage>The job context object is not supported by Action Service Framework.</LongMessage> 
    <ErrorCode>21843</ErrorCode> 
    <SeverityCode>Error</SeverityCode> 
    <ErrorParameters ParamID="0"><Value>AddItems</Value></ErrorParameters> 
    <ErrorParameters ParamID="1"><Value>AddItemRequestType</Value></ErrorParameters> 
    <ErrorClassification>RequestError</ErrorClassification> 
</Errors><Version>1021</Version><Build>E1021_UNI_API5_18478667_R1</Build></AddItemsResponse> 

当我试图用API资源管理器相同的XML。请求已通过。

有些问题与CURL我想。

回答

1

您指定X-EBAY-API-CALL-NAME作为为addItems

你的XML是一种AddItemRequest

这些必须匹配。 AddItem & AddItems是2个不同的调用。

+0

嘿谢谢你的回复。今天发现这一点。我卡住的地方现在是运送详情部分。任何想法是什么。不管怎么说,多谢拉! –