Hi, all
Who can say me about session token. How i can make it in script. In example PHP.
What is request i need make?
Who can say me about session token. How i can make it in script. In example PHP.
What is request i need make?
<?php
ob_start();
$sessionToken = getACookie();
ob_end_clean();
echo $sessionToken;
function getACookie(){
$loginEndpoint= "https://identitysso.betfair.com/api/login";
$cookie = "";
$username = "XXXXX";
$password = "ZZZZZZ";
$login = "true";
$redirectmethod = "POST";
$product = "home.betfair.int";
$url = "https://www.betfair.com/";
$fields = array
(
'username' => urlencode($username),
'password' => urlencode($password),
'login' => urlencode($login),
'redirectmethod' => urlencode($redirectmethod),
'product' => urlencode($product),
'url' => urlencode($url)
);
//open connection
$ch = curl_init($loginEndpoint);
//url-ify the data for the POST
$counter = 0;
$fields_string = "&";
foreach($fields as $key=>$value)
{
if ($counter > 0)
{
$fields_string .= '&';
}
$fields_string .= $key.'='.$value;
$counter++;
}
rtrim($fields_string,'&');
curl_setopt($ch, CURLOPT_URL, $loginEndpoint);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS,$fields_string);
curl_setopt($ch, CURLOPT_HEADER, true); // DO RETURN HTTP HEADERS
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // DO RETURN THE CONTENTS OF THE CALL
//execute post
$result = curl_exec($ch);
echo $result;
if($result == false)
{
echo 'Curl error: ' . curl_error($ch);
}
else
{
$temp = explode(";", $result);
$result = $temp[0];
$end = strlen($result);
$start = strpos($result, 'ssoid=');
$start = $start + 6;
$cookie = substr($result, $start, $end);
}
curl_close($ch);
return $cookie;
}
?>
Comment