0

我正在尝试编写一个简单的 PHP 客户端,以通过免费访问 API http://bdp.betfair.com/?option=com_content&task=view&id=33&Itemid=62从Betfair获取一些数据

我可以通过这种方式登录并获取会话令牌

$wsdl = 'https://api.betfair.com/global/v3/BFGlobalService.wsdl';
$soapClient = new SoapClient($wsdl); 
try {
    $ap_param = array(
        'request' => 
            array(
                'username' => 'my_username',
                'password' => 'my_password',
                'productId' => '82',    
                'ipAddress' => '',
                'locationId' => '',
                'vendorSoftwareId' => '',
            ),
        );  
    $response = $soapClient->__call("login", array($ap_param));
...

$response 是一个包含 sessionToken 参数的对象

但经过几次尝试后,恐怕我正在发送 APIRequestHeader 参数(http://bdp.betfair.com/docs/)格式错误,导致对任何调用(例如 getAllEventTypes)的响应总是返回相同的:NO_SESSION

一试...

$ap_param = array(
    'request' => 
        array(
            'header' => array(
                'session_token' => $response->Result->header->sessionToken,
                'clientStamp' => 0,
            ),          
        ),
    );      

再试一次...

$ap_param = array(
    'request' => 
        array(
            'session_token' => $response->Result->header->sessionToken,
            'clientStamp' => 0,
        ),
    ); 

还有很多其他尝试......但是

$response = $soapClient->__call("getAllEventTypes", array($ap_param));

$response 总是一样的

stdClass Object
(
    [Result] => stdClass Object
        (
            [header] => stdClass Object
                (
                    [errorCode] => NO_SESSION
                    [minorErrorCode] => 
                    [sessionToken] => 
                    [timestamp] => 2013-11-09T08:41:01.015Z
                )

            [eventTypeItems] => 
            [minorErrorCode] => 
            [errorCode] => API_ERROR
        )

)

这里有人遇到过同样的问题吗?

4

1 回答 1

0

那里愚蠢的错字错误...

session_token应该是sessionToken

$ap_param = array(
    'request' => 
        array(
            'header' => array(
                'sessionToken' => $response->Result->header->sessionToken,
                'clientStamp' => 0,
            ),          
        ),
    );  
于 2013-11-10T12:39:44.023 回答