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我想。
嘿謝謝你的回覆。今天發現這一點。我卡住的地方現在是運送詳情部分。任何想法是什麼。不管怎麼說,多謝拉! –