Hi,
Chris
I Think i’m not doing wrong, but i am running an error.
Thank you and I’m sorry.
rmoscat
TEST - 1
getdtrange.lua
local in_data = coronium.input()
local answer = coronium.php.run( ‘getdtrange’, in_data )
coronium.output( answer )
getdtrange.php
<?php
$in_data = json_decode(file_get_contents(‘php://input’));
function date_range($first, $last, $step = ‘+1 day’, $output_format = ‘d/m/Y’ ) {
$dates = array();
$current = strtotime($first);
$last = strtotime($last);
$key = 1;
while( $current <= $last ) {
$varkey = (string) $key;
$dates[$varkey] = date($output_format, $current) . ’ - ’ . date($output_format, strtotime($step, $current));
$current = strtotime($step, $current);
$key++;
}
return $dates;
}
$dates = date_range(“2014-01-01”, “2014-01-08”, “+1 day”, “mdY”);
$response = $dates;
print(json_encode($response));
?>
This is the error I get
ERROR -->
error: Expected value but found invalid token at character 1
errorCode: -2
TEST - 2
getdtrange.php
<?php
$in_data = json_decode(file_get_contents(‘php://input’));
$keyvalues = array();
$keyvalues[“1”] = “bar”;
$keyvalues[“2”] = “power”;
$keyvalues[“3”] = “power”;
$keyvalues[“4”] = “power”;
$response = $keyvalues;
print(json_encode($response));
?>
NOT ERROR
result:
1: bar
2: power
3: power
4: power