Php,Ebay Tradding Api错误无效的作业上下文类型

时间:2013-08-22 13:31:37

标签: php api soap ebay

我试图用ebay Tradding Api使用php和CURL在ebay上列出一个项目

所有内容(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>paypal@jccayer.com</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
)

有人有想法吗?

-------------------------------已编辑--------------- -------

好的当我从David T. Sadler那里拿到了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>paypal@jccayer.com</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>

1 个答案:

答案 0 :(得分: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:[替换您的设备]
    • X-EBAY-API-APP-NAME:[替换您的APPID]
    • X-EBAY-API-CERT-NAME:[替换您的CERTID]
    • X-EBAY-API-SITEID:2
    • X-EBAY-API-CALL-NAME:为addItems