PHP eBay API GeteBayOfficialTime 调用返回“不支持的 API 调用”错误

发布于 2024-11-26 18:46:46 字数 2580 浏览 0 评论 0原文

我试图从 eBay 提取卖家列表,每次运行此代码时,都会收到错误

API 调用“GeteBayOfficialTime”在此版本中无效或不受支持

我在带有 Zend Server 的 Mac 上运行此版本。

PHP 请求:

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>

I am trying to pull a seller list from eBay and every time I run this code, I get the error

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

I'm running this on a Mac with Zend Server.

Request in PHP:

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;  

Response:

<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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

守不住的情 2024-12-03 18:46:46

问题在于标头的定义方式,它应该是标准数组,而不是关联数组。请参阅下面的正确格式

$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'

:);

The problem is the way the headers are defined, it should be a standard array, not an associative array. See below for correct format:

$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'

);

半城柳色半声笛 2024-12-03 18:46:46

为了获得正确的 XML,您可以使用 API 测试工具 。您还可以选择要使用的 API 版本。只需选择您想要进行的调用,您就会获得 XML。该文档通常已经过时。

In order to get the correct XML you can use the API test tool. You can also choose which API version you would like to use. Just choose the call you want to make, and you will get the XML. The documentation is often outdated.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文