" . $xdat . "
" ;
$url = "http://publications.elia.be/Publications/Publications/WindForecasting.v1.svc/GetForecastGraphDataXml?beginDate=" . $curdat . "&endDate=" . $xdat . "&isOffshore=&isEliaConnected";
echo $url;
echo "
";
echo $t;
$xml=simplexml_load_file("$url") or die("Error: Cannot create object");
//print_r($xml);
foreach($xml->ForecastGraphItems->WindForecastingGraphItem as $Graph){
$fc = $Graph->Forecast;
echo $fc . "
";
$ra = $Graph->RunningAverage;
echo $ra . "
";
$lf = $Graph->LoadFactor;
echo $lf . "
";
$namespaces = $Graph->getNameSpaces(true);
$dc = $Graph->Time->children($namespaces['a']);
// "T ". $dc->DateTime;
$m = $dc->OffsetMinutes;
//echo $m;
//echo $m . "
";
$d= $dc->DateTime;
$time = new DateTime($d);
$tijd = $time->format('Y-m-d H:i:s');
$x = strtotime($tijd);
$nt = date('Y-m-d H:i:s', strtotime("+$m minutes", $x));
//echo " = ";
echo $nt;
echo "
";
//echo "OS " . $dc->OffsetMinutes;
echo "
";
echo "
";
$sql2 = "INSERT INTO Wind(WindDateTime, WindFC, WindLoadFac, WindRunAv) VALUES ('$nt', '$fc', '$lf', '$ra')";
$sql1 = "INSERT INTO Wind(WindDateTime, WindFC) VALUES ('$nt', '$fc')";
if ($ra ==0){
echo $sql1;
$sql = $sql1;
}
else {
echo $sql2;
$sql = $sql2;
}
$del = "DELETE FROM Wind WHERE WindDateTime = '$nt'";
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if ($conn->query($del) === TRUE) {
echo "old deleted";
} else {
echo "Error: " . $sql . "
" . $conn->error;
}
if ($conn->query($sql) === TRUE) {
echo "ok";
} else {
echo "Error: " . $sql . "
" . $conn->error;
}
$conn->close();
echo $sql;
echo "
";
}
?>