2015-07-10 120 views
1

我對每種方法都一直有DSC-0021錯誤,除了getAccountFunds。betfair php api - error 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 = '{ 「錢包」: 「英國」}';

    $ 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);} $ res = send_request($ api_method,$ action,$ params);} $ res = send_request($ api_method,$ action,$ params);

  • sessionToken是有效的,關鍵得

感謝

回答