Skip to content

Instantly share code, notes, and snippets.

@s0ren
Last active December 9, 2015 11:36
Show Gist options
  • Save s0ren/e5958d9e8d4d4df99c76 to your computer and use it in GitHub Desktop.
Save s0ren/e5958d9e8d4d4df99c76 to your computer and use it in GitHub Desktop.
Demo af rest api mofd rejseplanen
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Afgange fra Fasanvej</title>
</head>
<body>
<?php
$config["baseUrl"] = "http://xmlopen.rejseplanen.dk/bin/rest.exe";
//$page = file_get_contents($config['baseUrl'] . '/location?input=Nordre Fasanvej 27, 2000 Frederiksberg');
$c = curl_init($config['baseUrl'] . '/departureBoard?id=000001273&date=09.12.2015&time=10.50&format=json');
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($c);
curl_close($c);
$responseArray = json_decode($response, TRUE);
foreach ($responseArray['DepartureBoard']['Departure'] as $id => $departure )
{
if (isset($departure['rtTime']))
{
$time = $departure['rtTime'];
}
else
{
$time = $departure['time'];
}
echo "<div class='depName'>$departure[name]</div>";
echo "<div class='depTime'>$time</div>";
echo '<pre>';
var_dump($departure);
echo '</pre>';
}
echo '<pre>';
var_dump($responseArray['DepartureBoard']['Departure']);
echo $response;
echo '</pre>';
?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment