Thankyou so much for your help and assistance. The code below is straight from the example project, appreciate any help you can give me as Id love to be tinkering with this over the weekend.
<?php
error_reporting(E_ALL); ini_set('display_errors', 1);
date_default_timezone_set("Australia/Sydney");
$apiEndpoint = 'https://api.transport.nsw.gov.au/v1/tp/';
$apiCall = 'departure_mon'; // Set the location and time parameters
$when = time(); // Now
$stop = '10101331'; // Domestic Airport Station // Build the request parameters
$params = array( 'outputFormat' => 'rapidJSON', 'coordOutputFormat' => 'EPSG:4326', 'mode' => 'direct', 'type_dm' => 'stop', 'name_dm' => $stop, 'depArrMacro' => 'dep', 'itdDate' => date('Ymd', $when), 'itdTime' => date('Hi', $when), 'TfNSWDM' => 'true' );
$url = $apiEndpoint . $apiCall . '?' . http_build_query($params);
// Create a stream
$opts = [
"http" => [
"method" => "GET",
"header" => "Authorization: apikey XXXXXX API KEY XXXXXX\r\n"
]
];
// Perform the request and build the JSON response data
$context = stream_context_create($opts);
$response = file_get_contents($url, false, $context);
$json = json_decode($response, true);
$stopEvents = $json['stopEvents'];
// Loop over returned stop events
foreach ($stopEvents as $stopEvent) {
// Extract the route information
$transportation = $stopEvent['transportation'];
$routeNumber = $transportation['number'];
$destination = $transportation['destination']['name']; // In the case of a train, the location includes platform information
$location = $stopEvent['location']; // Determine how many minutes until departure
$time = strtotime($stopEvent['departureTimePlanned']);
$countdown = $time - time();
$minutes = round($countdown / 60); // Output the stop event with a countdown timer
echo $minutes . "m from " . $location['name'] . "\n<br />";
echo $routeNumber . " to " . $destination . "\n\n<br /><br />";
}
echo "end";
?>