unable to retrieve api results

Trying to retrieve information from an API and display it in a table.

[php]

Current Dublin Bus Times.

Stop Number: [/php]

[php]<?php
$stopID = $_GET[‘stopid’];
$url = “https://data.dublink…rmation?stopid=” . $_GET[‘stopid’] . “&format=json”;

// Process the JSON and check for errors
$json = file_get_contents($url);
$array = json_decode($json,true);

if ($stopID != $array[“stopid”]) {
// Get the values for $errorCode and $errorMessage
$errorCode = $array[“errorcode”];
$errorMessage = $array[“errormessage”];

echo "Error: ";
echo $errorCode;
echo $errorMessage;

} else {
// Get the values
$duetime = $array[“duetime”];
$destination = $array[“destination”];
$route = $array[“route”];

echo "

“;
echo " ”;
echo " ”;
echo “
Stop Number Route Due Time Destination
" . $stopID . “ ” . $route . “ ” . $duetime . “ ” . $destination . “
”;

}

?>
[/php]

What results are you getting?

OP already got an answer to the problem on another forum. There are several undefined index errors that he would have seen if he turned on error reporting.

Sponsor our Newsletter | Privacy Policy | Terms of Service