2013-08-22 32 views
1

我試着使用PHP列出易趣上的物品與eBay的舾裝阿比和捲曲PHP,易趣舾裝API錯誤無效的作業上下文類型

一切(XML和我的腳本)看行或者我只是不明白什麼即時做錯了。

這是我的要求

<?xml version="1.0" encoding="utf-8"?> 
<AddItemsRequest xmlns="urn:ebay:apis:eBLBaseComponents"> 
<ErrorLanguage>en_US</ErrorLanguage> 
<AddItemRequestContainer> 
<MessageID>100</MessageID> 
<Item> 
<BuyItNowPrice>238.00</BuyItNowPrice> 
<CategoryMappingAllowed>true</CategoryMappingAllowed> 
<ConditionID>1000</ConditionID> 
<Country>CA</Country> 
<Currency>CAD</Currency> 
<Title>TEST</Title> 
<Description>DEscription</Description> 
<DispatchTimeMax>3</DispatchTimeMax> 
<ListingDuration>Days_7</ListingDuration> 
<ListingType>FixedPriceItem</ListingType> 
<PaymentMethods>PayPal</PaymentMethods> 
<PayPalEmailAddress>[email protected]</PayPalEmailAddress> 
<PictureDetails> 
<Item.PictureDetails.PictureURL> 
http://www.jccayer.com/productphoto/2793-22-1_ep1.jpg 
</Item.PictureDetails.PictureURL> 
<PictureURL>http://www.jccayer.com/productphoto/2793-22-1_ep1.jpg</PictureURL> 
</PictureDetails> 
<PostalCode>K0A1M0</PostalCode> 
<PrimaryCategory> 
<CategoryID>279</CategoryID> 
</PrimaryCategory> 
<Quantity>1</Quantity> 
<ReturnPolicy> 
<ReturnsAcceptedOption>ReturnsAccepted</ReturnsAcceptedOption> 
<RefundOption>MoneyBack</RefundOption> 
<ReturnsWithinOption>Days_30</ReturnsWithinOption> 
<Description>Text description of return policy details</Description> 
<ShippingCostPaidByOption>Buyer</ShippingCostPaidByOption> 
</ReturnPolicy> 
<ShippingDetails> 
<ShippingType>Flat</ShippingType> 
<ShippingServiceOptions> 
<ShippingServicePriority>1</ShippingServicePriority> 
<ShippingService>CA_UPSStandardCanada</ShippingService> 
<ShippingServiceCost>21.50</ShippingServiceCost> 
</ShippingServiceOptions> 
</ShippingDetails> 
<Site>Canada</Site> 
<UUID>4d8b04a3ae054a978a66848fafd524c9</UUID> 
</Item> 
</AddItemRequestContainer> 
<RequesterCredentials> 
<eBayAuthToken>[INSERT YOUR OWN AUTH TOKEN]</eBayAuthToken> 
</RequesterCredentials> 
</AddItemsRequest> 

,並即時得到這個作爲性反應。

Array 
(
[Timestamp] => 2013-08-22T13:16:02.397Z 
[Ack] => Failure 
[Errors] => Array 
    (
     [ShortMessage] => Invalid job context type 
     [LongMessage] => The job context object is not supported by Action Service Framework. 
     [ErrorCode] => 21843 
     [SeverityCode] => Error 
     [ErrorParameters] => Array 
      (
       [0] => Array 
        (
         [@attributes] => Array 
          (
           [ParamID] => 0 
          ) 

         [Value] => AddItem 
        ) 

       [1] => Array 
        (
         [@attributes] => Array 
          (
           [ParamID] => 1 
          ) 

         [Value] => AddItemsRequestType 
        ) 

      ) 

     [ErrorClassification] => RequestError 
    ) 

[Version] => 833 
[Build] => E833_UNI_API5_16246498_R1 
) 

有人有想法嗎?

-------------------------------編輯-------------- --------

好正如我接到了大衛·薩德勒噸的awnser他建議我使用StartingPrice代替BuyItNowPrice

所以這是我做過什麼, 大衛說他嘗試能夠通過API測試工具,以便運行我的XML是我做的和 我沒有在那邊工作太

這裏是我的頭,XML請求和性反應的

頁眉

X-EBAY-API-COMPATIBILITY-LEVEL:833 
X-EBAY-API-DEV-NAME:76803363-a07b-4c24-b5c7-f38ce3dd1ba7 
X-EBAY-API-APP-NAME:JeanClau-bd2d-4e64-9466-41fbecfb8bb6 
X-EBAY-API-CERT-NAME:4624a573-0320-4604-ac18-f7fc07d0ea8b 
X-EBAY-API-SITEID:2 
X-EBAY-API-CALL-NAME:AddItem 

XML請求

<?xml version="1.0" encoding="utf-8"?> 
<AddItemsRequest xmlns="urn:ebay:apis:eBLBaseComponents"> 
<ErrorLanguage>en_US</ErrorLanguage>  
<AddItemRequestContainer>  
<MessageID>100</MessageID>  
<Item>  
<StartingPrice>238.00</StartingPrice>  
<CategoryMappingAllowed>true</CategoryMappingAllowed>  
<ConditionID>1000</ConditionID>  
<Country>CA</Country>  
<Currency>CAD</Currency>  
<Title>TEST</Title>  
<Description>DEscription</Description>  
<DispatchTimeMax>3</DispatchTimeMax>  
<ListingDuration>Days_7</ListingDuration>  
<ListingType>FixedPriceItem</ListingType>  
<PaymentMethods>PayPal</PaymentMethods>  
<PayPalEmailAddress>[email protected]</PayPalEmailAddress>  
<PictureDetails>  
<Item.PictureDetails.PictureURL>  
http://www.jccayer.com/productphoto/2793-22-1_ep1.jpg  
</Item.PictureDetails.PictureURL>  
<PictureURL>http://www.jccayer.com/productphoto/2793-22-1_ep1.jpg</PictureURL>  
</PictureDetails>  
<PostalCode>K0A1M0</PostalCode>  
<PrimaryCategory>  
<CategoryID>279</CategoryID>  
</PrimaryCategory>  
<Quantity>1</Quantity>  
<ReturnPolicy>  
<ReturnsAcceptedOption>ReturnsAccepted</ReturnsAcceptedOption>  
<RefundOption>MoneyBack</RefundOption>  
<ReturnsWithinOption>Days_30</ReturnsWithinOption>  
<Description>Text description of return policy details</Description>  
<ShippingCostPaidByOption>Buyer</ShippingCostPaidByOption>  
</ReturnPolicy>  
<ShippingDetails>  
<ShippingType>Flat</ShippingType>  
<ShippingServiceOptions>  
<ShippingServicePriority>1</ShippingServicePriority>  
<ShippingService>CA_UPSStandardCanada</ShippingService>  
<ShippingServiceCost>21.50</ShippingServiceCost>  
</ShippingServiceOptions>  
</ShippingDetails>  
<Site>Canada</Site>  
<UUID>4d8b04a3ae054a978a66848fafd524c9</UUID>  
</Item>  
</AddItemRequestContainer>  
<RequesterCredentials>  
<eBayAuthToken>[INSERT YOUR OWN AUTH TOKEN]</eBayAuthToken>  
</RequesterCredentials>  
</AddItemsRequest> 

性反應

<?xml version="1.0" encoding="UTF-8"?> 
<AddItemsResponse xmlns="urn:ebay:apis:eBLBaseComponents"> 
    <Timestamp>2013-08-23T13:31:10.575Z</Timestamp> 
    <Ack>Failure</Ack> 
    <Errors> 
    <ShortMessage>Auth token is invalid.</ShortMessage> 
    <LongMessage>Validation of the authentication token in API request failed.</LongMessage> 
    <ErrorCode>931</ErrorCode> 
    <SeverityCode>Error</SeverityCode> 
    <ErrorClassification>RequestError</ErrorClassification> 
    </Errors> 
    <Version>833</Version> 
    <Build>E833_UNI_API5_16246498_R1</Build> 
</AddItemsResponse> 

回答

2

唯一不對您的要求是,BuyItNowPrice元素無效的FixedPriceItem上市。您需要將其更改爲StartingPrice。除此之外,請求是好的。我甚至將您的XML複製並粘貼到eBay API測試工具中,並列出了該項目。 http://cgi.sandbox.ebay.com/110121707611

沒有看到您如何使用PHP和Curl發送請求,我只能推薦以下內容。

  • 確保您正在向正確的終點發送POST請求。
  • 問題可能發生。確保此字符串中的第一個字符是XML請求。
  • 確保CURL使用正確的值發送以下HTTP標頭。
    • X-EBAY-API兼容性-LEVEL:833
    • X-EBAY-API-DEV-NAME:[WITH YOUR DEVID REPLACE]
    • X-EBAY-API-APP-NAME:[取代YOUR APPID]
    • X-EBAY-API-CERT-NAME:[WITH YOUR CERTID REPLACE]
    • X-EBAY-API-SITEID:2
    • X-EBAY-API-CALL-NAME:爲addItems
+0

T非常感謝您的意見。 但我只是測試它,它的基礎是一樣的。 從我的理解,我不得不改變這個元素 是corect? 我看着我的標題,併發送它像你一樣的建議我 –

+0

由於它不是開始價格,但StartPrice 但你讓我意識到謝謝! :) –