2011-07-29 76 views
3

我試圖從eBay和我每次運行此代碼時拉暢銷書名單,我得到的錯誤PHP的eBay API「不支持的API調用」錯誤

The API call "GeteBayOfficialTime" is invalid or not supported in this release

我用Zend Server在Mac上運行它。

CODE:

define('XML_POST_URL', 'https://api.sandbox.ebay.com/ws/api.dll'); 

$theData =' 
    <?xml version="1.0" encoding="utf-8"?> 
    <GetSellerListRequest xmlns="urn:ebay:apis:eBLBaseComponents"> 
    <RequesterCredentials> 
    <eBayAuthToken>My Auth Key</eBayAuthToken> 
    </RequesterCredentials> 
     <Pagination ComplexType="PaginationType"> 
     <EntriesPerPage>1</EntriesPerPage> 
    <PageNumber>1</PageNumber> 
    </Pagination> 
    <WarningLevel>Low</WarningLevel> 
    <StartTimeFrom>2011-07-12T21:59:59.005Z</StartTimeFrom> 
    <StartTimeTo>2011-07-30T21:59:59.005Z</StartTimeTo> 
    <DetailLevel>ReturnAll</DetailLevel> 
    </GetSellerListRequest> 
'; 

$headers = array(
    'Content-Type' => 'text/xml', 
    'X-EBAY-API-COMPATIBILITY-LEVEL' => '727', 
    'X-EBAY-API-DEV-NAME' => '03dbea79-6089-4a00-8b3f-3114882e5d07', 
    'X-EBAY-API-APP-NAME' => 'sarfaraz-6e72-49e2-a7c0-ce2d2a48702b', 
    'X-EBAY-API-CERT-NAME' => 'd8382047-b425-40d6-8250-bac1497dc510', 
    'X-EBAY-API-SITEID' => '0', 
    'X-EBAY-API-CALL-NAME' => 'GetSellerList' 
); 

/** 
* Initialize handle and set options 
*/ 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, XML_POST_URL); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $theData); 
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 

/** 
* Execute the request 
*/ 
$result = curl_exec($ch); 

/** 
* Close the handle 
*/ 
curl_close($ch); 

/** 
* Output the results and time 
*/ 
header('Content-Type: text/xml'); 
echo $result; 

結果:

<GeteBayOfficialTimeResponse> 
    <Timestamp>2011-07-29 15:59:21</Timestamp> 
    <Ack>Failure</Ack> 
    <Errors> 
     <ShortMessage>Unsupported API call.</ShortMessage> 
     <LongMessage>The API call "GeteBayOfficialTime" is invalid or not supported in this release.</LongMessage> 
     <ErrorCode>2</ErrorCode> 
     <SeverityCode>Error</SeverityCode> 
     <ErrorClassification>RequestError</ErrorClassification> 
    </Errors> 
    <Build>13564081</Build> 
</GeteBayOfficialTimeResponse> 
+0

我已經開始收到這個錯誤,它已經工作了多年。任何人有任何關於eBay API的變化的想法? – Jamie

回答

1

爲了得到正確的XML可以使用API test tool。你也可以選擇你想使用的API版本。只要選擇你想要的呼叫,你就會得到XML。文檔通常過時。

8

問題是標題的定義方式,它應該是一個標準數組,而不是一個關聯數組。請參閱下面的正確格式:

$headers = array(
'Content-Type: text/xml', 
'X-EBAY-API-COMPATIBILITY-LEVEL: 727', 
'X-EBAY-API-DEV-NAME: 03dbea79-6089-4a00-8b3f-3114882e5d07', 
'X-EBAY-API-APP-NAME: sarfaraz-6e72-49e2-a7c0-ce2d2a48702b', 
'X-EBAY-API-CERT-NAME: d8382047-b425-40d6-8250-bac1497dc510', 
'X-EBAY-API-SITEID: 0', 
'X-EBAY-API-CALL-NAME: GetSellerList' 

);

+1

最佳答案就在那裏 – barners