Sixtens hemsida Uppgifter Blogg Om

VED House bokningssystem

Gå till sida

Källkod

api/

database.php

api.php

ved/

monthBookingData.php

openingHoursException.php

bookingData.php

dayTimeframes.php

bookings.php

admin/

revokeToken.php

authorization.php

login.php

modules/

vedDatabase.php

utility.php

gyar/

log.php

auth/

revokeToken.php

authorization.php

login.php

station/

settings.php

log.php

modules/

gyarDatabase.php

databaseConnection.php

database.php

utility.php

credentials.json

weather/

latest.php

old.php

admin/

index.html

changeTimetable.html

login.html

js/

login.js

modules.js

admin.js

header.js

changeTimetable.js

cron/

vedClearExpiredTokens.php

api/gyar/weather/latest.php

1 lines
<?php
# latest.php
# API endpoint
# Fil för att hämta den senaste väderdatan från en viss mätpunkt.

require_once "gyar/modules/utility.php";

# Hämtar den senaste tillgängliga väderdatan för dagen.
$functionGET = function () {
    require 
"gyar/modules/database.php";

    
$params = [
        
"pointId" => $_GET["pointId"]
    ];
    
$dateData $db->query(
        
"SELECT mp.latitude, mp.longitude, UNIX_TIMESTAMP(spt.timestamp) AS 'timestamp', wd.temperature, wd.humidity, wd.airPressure, wd.downfall, wd.windSpeed, wd.windDirection, UNIX_TIMESTAMP(ws.nextExpectedUpload) AS 'nextExpectedUpload' FROM measuringPoint mp JOIN stationPointInstance sp ON sp.pointId = mp.pointId JOIN weatherStation ws on sp.stationId = ws.stationId JOIN stationPointTimeData spt ON spt.stationPointInstanceId = sp.stationPointInstanceId JOIN weatherData wd ON wd.stationPointDataId = spt.stationPointDataId WHERE mp.pointId=:pointId ORDER BY spt.timestamp DESC;",
        
$params
    
);

    
$returnData = [
        
"latitude" => $dateData["latitude"],
        
"longitude" => $dateData["longitude"],
        
"timestamp" => $dateData["timestamp"],
        
"nextExpectedUpload" => $dateData["nextExpectedUpload"],
        
"data" => [
            
"temperature" => $dateData["temperature"],
            
"humidity" => $dateData["humidity"],
            
"airPressure" => $dateData["airPressure"],
            
"downfall" => $dateData["downfall"],
            
"windSpeed" => $dateData["windSpeed"],
            
"windDirection" => $dateData["windDirection"],
        ],
    ];

    return 
$returnData;
};

$api = new APIEndpoint();

$httpGET = new APIMethod("GET"$functionGET);
$httpGET->setRequiredGETParameters(array("pointId"));
$api->addMethod($httpGET);

return 
$api;
?>