// The api key from Scooty's app/account: iPtAHWdOVLEtgkaymXoMHVVg
// The api key from Scooty's app/account: iPtAHWdOVLEtgkaymXoMHVVg
// Below is the static html to generate the map, it can also be done more dynamically using https://github.com/LuminFire/leaflet-php but that might be overkill
// array of scooters
// array of scooters
@ -10,10 +11,21 @@ $scooters = array(
'https://opencoil.show/test-json.php?scooterID=2'
'https://opencoil.show/test-json.php?scooterID=2'
);
);
// for each
// for each scooter in array get the json (TODO, for each, safe to file/database?)
echo callAPI($scooters[0]);
$getJSON = callAPI($scooters[0]);
// decode JSON data to PHP associative array
$arr = json_decode($getJSON, true);
// access values from the associative array
$lat = $arr["data"]["attributes"]["lat"]; // get lattitude
$lng = $arr["data"]["attributes"]["lng"]; // get longitude
$lst = $arr["data"]["attributes"]["lastLocationUpdate"]; // get time of last position
// construct lat/lon for use in leafet
$pos = $lat.', '.$lng;
// TODO save json to file?...mmm one big one? seperate ones, timestamped ones?
@ -26,6 +38,14 @@ echo callAPI($scooters[0]);
// Custom functions
// Custom functions
function checkModified($file, $expiration){ //check if file is older than expiration time