blueweather/api/json.php

40 lines
902 B
PHP
Raw Normal View History

2019-07-13 20:02:47 +02:00
<?php
/**
* BlueWeather
*
* PHP version 7.2
*
* @param locId
* @param range (range[from]: from UNIX time; range[to]: to UNIX time)
2019-07-16 17:42:33 +02:00
* @param maxVals (maximum measvals to be transmitted; if more are present
* in the timespan, the avarage will be calculated)
2019-07-13 20:02:47 +02:00
*
* @category Tools
* @package BlueWeather
* @author Dorian Zedler <dorian@itsblue.de>
* @license GPLV3 gpl.com
* @link itsblue.de
*/
require_once './config.php';
2019-07-15 20:29:19 +02:00
require_once './blueweather.php';
2019-07-13 20:02:47 +02:00
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
2019-07-15 20:29:19 +02:00
$blueweather = new BlueWeather($config);
2019-07-13 20:02:47 +02:00
if (isset($_GET['locId'])) {
// get data of given location
2019-07-16 17:42:33 +02:00
$data = $blueweather->getLocationData(
$_GET['locId'], $_GET['range'], $_GET['maxVals']
);
2019-07-13 20:02:47 +02:00
} else {
2019-07-15 20:29:19 +02:00
$data = $blueweather->getAllLocations();
2019-07-13 20:02:47 +02:00
}
http_response_code(200);
echo json_encode($data);