1

除了 getAccountFunds 之外,我在每种方法上总是出现 DSC-0021 错误。

我有这个请求功能

function send_request($api_method, $action, $params){

    if(!isset($_SESSION['session']) or empty($_SESSION['session'])){
        $_SESSION['session'] = login_non_interactive(APP_KEY);
    }

    $endpoint = 'https://api.betfair.com/exchange/account/json-rpc/v1';
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $endpoint);
    curl_setopt($ch, CURLOPT_POST, 1);


    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'X-Application: ' . APP_KEY,
        'X-Authentication: ' . $_SESSION['session'],
        'Accept: application/json',
        'Content-Type: application/json'
    ));

    $postData =
        '[{ "jsonrpc": "2.0", "method": "'.$api_method.'/v1.0/' . $action . '", "params" :' . $params . ', "id": 1}]';

    curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);

    if( ! $response = curl_exec($ch)){
        trigger_error(curl_error($ch)); 
    }

    $http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);

    if ($http_status == 200) {
        return json_decode($response);
    } else {
        echo  'Error: ' . $response;
    }
}
  • 对于余额(getAccountFunds),我得到了有效且正常的响应

    $params = '{"钱包":"UK"}';

    $action = 'getAccountFunds';

    $api_method = 'AccountAPING';

    $balance = send_request($api_method, $action, $params);

  • 对于其他方法,我总是得到 DSC-0021

    $params = '{"过滤器":{}}';

    $action = 'listEventTypes';

    $api_method = 'SportsAPING';

    $res = send_request($api_method, $action, $params);

  • sessionToken 是有效的,也是密钥

谢谢

4

1 回答 1

1

不只是错误的终点吗?体育博彩 api 与帐户 api 位于不同的端点上。请参阅此处的帐户此处的投注

于 2015-07-11T13:01:10.183 回答