diff --git a/website/curl.php b/website/curl.php index 3689ed3..f01639e 100644 --- a/website/curl.php +++ b/website/curl.php @@ -11,6 +11,15 @@ $scooters = array( 'https://opencoil.show/test-json.php?scooterID=2' ); +//make it like this +$scooters = array( +//'https://platform.tier-services.io/v1/vehicle/fbd739d6-554f-4eaf-bd9c-afe3d501c94b', +'https://opencoil.show/test-json.php?scooterID=1', +'https://opencoil.show/test-json.php?scooterID=2' +); + + + // for each scooter in array get the json (TODO, for each, safe to file/database?) $getJSON = callAPI($scooters[0]); @@ -21,18 +30,48 @@ $arr = json_decode($getJSON, true); $lat = $arr["data"]["attributes"]["lat"]; // get lattitude $lng = $arr["data"]["attributes"]["lng"]; // get longitude $lst = $arr["data"]["attributes"]["lastLocationUpdate"]; // get time of last position +$rnt = $arr["data"]["attributes"]["isRentable"]; // check if scooter is rentable, +$act = $arr["data"]["attributes"]["state"]; // check if scooter is ACTIVE or MAINTAINANCE -// construct lat/lon for use in leafet -$pos = $lat.', '.$lng; +//check if scooter is rentable +// if($rnt == true){ +// echo "rentable"; +// } else { +// echo "gallery not available"; +// }; + +//check if scooter status (if ACTIVE) +// if($act === "ACTIVE"){ +// echo "scooter is active"; +// } else { +// echo "scooter is in repair"; +// }; -// TODO save json to file?...mmm one big one? seperate ones, timestamped ones? +//// make date time file------ +// construct lat/lon for use in leafet +$pos = $lat.', '.$lng; +// TODO save json to file?...mmm one big one? seperate ones, timestamped ones? +// 60 second update interval +// make timestamp file like original python one! to check for updates +// make new custom json: +// scooter 1/marker time1 { lat long } +// time2 { lat long } +// scooter 2/marker time1 { lat long } +// time2 { lat long } +// +// +// for each +// check if lastlocation is different...if update > latest file (map file..) +// check if is rentable +// 2 json files: is retantable, latlong, id, status +// historical: every 60 sec needs update..even tho no state changes @@ -72,17 +111,51 @@ function callAPI($url){ + + + + + + + + + + + + + + + + + + + + +