ManageBGL API Sample with PHP

The ManageBGL API sample below allows you to login, retrieve an access token, and then add a BGL.

Login / Retrieve an Access Token

$url = "https://www.PredictBGL.com/api/1.0/login.json?email=" . urlencode($_POST['email']) . "&password=" . urlencode($_POST['password']);
$res = json_decode( file_get_contents($url), true);
if ($res['result']) {
  //success
  $token = $res['token'];
} else {
  //failed
}

Add Log

$url = "https://www.PredictBGL.com/api/1.0/add.json?token=" . urlencode($_POST['token']) .
"&value=" . urlencode($_POST['value']) .
"&notes=" . urlencode($_POST['notes']) .
"&log_type=" . urlencode($_POST['log_type']);
$res = json_decode( file_get_contents($url), true);
if ($res['result']) {
  //success
} else {
  //failed
}

Logout

$url = "https://www.PredictBGL.com/api/1.0/logout.json?token=" . urlencode($_POST['token']);
$res = json_decode( file_get_contents($url), true);
if ($res['result']) {
  //success
} else {
  //failed
}