...
Add the following two lines to the sportsApingRequest function after the curl_init:
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false ); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0 ); |
2) Correct fix for production applications:
...
Code Block |
---|
function sportsApingRequest($appKey, $sessionToken, $operation, $params)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://beta-api.betfair.com/json-rpc");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'X-Application: ' . $appKey,
'X-Authentication: ' . $sessionToken,
'Accept: application/json',
'Content-Type: application/json'
));
$postData =
'[{ "jsonrpc": "2.0", "method": "SportsAPING/v1.0/' . $operation . '", "params" :' . $params . ', "id": 1}]';
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
$response = json_decode(curl_exec($ch));
curl_close($ch);
if (isset($response[0]->error)) {
echo 'Call to api-ng failed: ' . "\n";
echo 'Response: ' . json_encode($response);
exit(-1);
} else {
return $response;
}
}
|
...
Code Block |
---|
function sportsApingRequest($appKey, $sessionToken, $operation, $params)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://beta-api.betfair.com/rest/v1/$operation/");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'X-Application: ' . $appKey,
'X-Authentication: ' . $sessionToken,
'Accept: application/json',
'Content-Type: application/json'
));
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
$response = json_decode(curl_exec($ch));
$http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($http_status == 200) {
return $response;
} else {
echo 'Call to api-ng failed: ' . "\n";
echo 'Response: ' . json_encode($response);
exit(-1);
}
} |
...