0

我正在尝试使用 eBatNS SOAP API 获取会话 ID。

进行调用的函数非常简单,但总是返回身份验证错误。你可以看到下面的功能

public function get_ebay_session()
    {
        error_reporting(0);
        $ruName = "Forward_Thinker-ForwardT-57fe-4-rybapdi";
        $sessionID = "";

        //Connect to eBay and get a list of all products
        require_once 'eBay/EbatNs/EbatNs_ServiceProxy.php';
        require_once 'eBay/EbatNs/GetSessionIDRequestType.php';
        require_once 'eBay/EbatNs/EbatNs_Logger.php';

        //Get a SessionID
        $session = new EbatNs_Session('eBay/config/ebay.config.php');
        print_r($session);
        echo "<hr>";

        $cs = new EbatNs_ServiceProxy($session);
        $cs->attachLogger(new EbatNs_Logger(false, 'stdout', true, false));
        print_r($cs);
        echo "<hr>";

        $req = new GetSessionIDRequestType();
        $req->setRuName($ruName);
        print_r($req);
        echo "<hr>";

        $result = $cs->GetSessionID($req);

        $sessionID = $result->SessionID;

        print_r($result);
        echo "<hr>";

        session_start();
        $_SESSION['eBaySessionID'] = $sessionID;

        $return = $ruName."\n".$sessionID;
        $this->set(compact('return'));
    }

如您所见,我附加了一个记录器。记录器显示这是正在发出的请求。

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns="urn:ebay:apis:eBLBaseComponents" ><soap:Header><RequesterCredentials><eBayAuthToken>AgAAAA**AQAAAA**aAAAAA**wS7oUQ**nY+sHZ2PrBmdj6wVnY+sEZ2PrA2dj6wHloSkD5aGog+dj6x9nY+seQ**It4BAA**AAMAAA**CB7yrHTyG3kQbA6KOwf0ZO2MqyPs/Dfn5u5r8ZDVGeWNvB</eBayAuthToken><Credentials><AppId>ForwardT-57fe-41ea-b90e-52fd0b541b88</AppId><DevId>5eefba38-e226-4876-9ada-d8743f571aeb</DevId><AuthCert>b57984cb-ba9c-430c-a8fc-c08f9ac46e75</AuthCert></Credentials></RequesterCredentials></soap:Header><soap:Body><GetSessionIDRequest><Version><![CDATA[815]]></Version><RuName><![CDATA[Forward_Thinker-ForwardT-57fe-4-rybapdi]]></RuName></GetSessionIDRequest></soap:Body></soap:Envelope>

这是返回的响应:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <soapenv:Body>
  <soapenv:Fault>
   <faultcode xmlns:ns1="http://xml.apache.org/axis/">ns1:FailedCheck</faultcode>
   <faultstring>Authorisation token is invalid.</faultstring>
   <faultactor>http://www.ebay.com/ws/websvc/eBayAPI</faultactor>
   <detail>
    <FaultDetail>
     <ErrorCode>931</ErrorCode>
     <Severity>Error</Severity>
     <DetailedMessage>Validation of the authentication token in API request failed.</DetailedMessage>
    </FaultDetail>
   </detail>
  </soapenv:Fault>
 </soapenv:Body>
</soapenv:Envelope>

我的 ebay.config.php 文件包含所有正确的键,据我所知,所有正确的信息。有没有人有任何解决技巧?

丹尼

4

1 回答 1

1

此问题是由 eBatNS API 从请求中的先前请求发送令牌以获取新令牌引起的。ebay 不支持这个。

这可以通过将会话上的令牌模式设置为 0 或 false 来解决。

$session->setTokenMode(0)
于 2013-09-24T14:36:15.297 回答