Skip to content

Instantly share code, notes, and snippets.

@pitkane
Last active October 8, 2015 08:02
Show Gist options
  • Save pitkane/a0e074411b2a8556b058 to your computer and use it in GitHub Desktop.
Save pitkane/a0e074411b2a8556b058 to your computer and use it in GitHub Desktop.
<?php
require_once('workflows.php');
$w = new Workflows();
// $query = ltrim($argv[1]);
// $parts = explode(' ', $query);
// echo "\n\n New Run \n\n";
$data = $w->request( 'http://liiga.fi/media/game-tracking/today.json' );
// $data = json_decode($data);
// echo $data->{'today'};
// echo $data;
$data = json_decode($data, true);
$today = $data['today'];
$current = $data['dates']['current']['isoformat'];
if ($today == $current) {
// today there are games to be played ;)
echo "Liiga, tänään " . $data['dates']['current']['short'] . " " . $data['dates']['current']['date'] . " pelaavat: \n\n";
foreach($data['games'] as $value)
{
echo "\t" . $value['home']['name'] . " - " . $value['away']['name'] . "\n";
echo "\t1: " . $value['latest-event']['wager']['odds-1'] .
"\tX: " . $value['latest-event']['wager']['odds-X'] .
"\t2: " . $value['latest-event']['wager']['odds-2'] . "\n";
echo "\t" . $value['status-short'] . "\n\n";
}
}
else {
// no games today, my love has gone away
// display: latest scores, and next games, dunno which first
$request_url = "http://liiga.fi/media/game-tracking/" . $data['dates']['next']['isoformat'] . ".json";
$data = $w->request( $request_url );
$data = json_decode($data, true);
echo "Liiga, Ei pelejä tänään :( Seuraavat " . $data['dates']['current']['short'] . " " . $data['dates']['current']['date'] . " (";
foreach($data['games'] as $value) {
// echo "moro";
echo $value['home']['name'] . "-" . $value['away']['name'];
if ($value === end($data['games'])) {
echo ")";
} else {
echo ", ";
}
}
}
// echo "\n\n End of Run";
// echo "moro";
// echo $w->toxml();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment