Exemplo n.º 1
0
    die;
}
if (!isset($_GET['id'])) {
    die;
}
$q = $_GET['q'];
$id = (int) $_GET['id'];
$logger = new EmonLogger();
require "PHPFina.php";
$phpfina = new PHPFina();
$phpfina->dir = $datadir;
header('Content-Type: application/json');
switch ($q) {
    case "create":
        if (isset($_GET['apikey']) && $apikey == $_GET['apikey']) {
            print $phpfina->create($id, array("interval" => get('interval'), "columns" => get('columns')));
        }
        break;
    case "post":
        if (isset($_GET['apikey']) && $apikey == $_GET['apikey']) {
            $time = time();
            print json_encode($phpfina->post($id, $time, explode(",", get('values'))));
        }
        break;
    case "data":
        print json_encode($phpfina->get_data($id, get('start'), get('end'), get('interval'), get('skipmissing'), get('limitinterval')));
        break;
    case "lastvalue":
        print json_encode($phpfina->lastvalue($id));
        break;
}