influxdb-php
influxdb-php copied to clipboard
Code 500
Hello guys i have a problem using the PHP_Client. On my Xampp Local Machine (Windows 10) everthing works great. But if i put the exact same files on my Linux VPS the Server gives me a 500 Code:
Can someone maybe help me ?
Here ist my Code:
<?php
require __DIR__ . '\..\vendor\autoload.php';
use InfluxDB2\Client;
use InfluxDB2\Model\WritePrecision;
use InfluxDB2\Point;
echo getdata("Jürgen ", "M_AC_Power");
function getdata($kunde,$wert)
{
# You can generate a Token from the "Tokens Tab" in the UI
$token = '';
$org = 'JH';
$bucket = 'PV-Daten';
$client = new Client([
"url" => "http://95.111.224.215:8086",
"token" => $token,
]);
$query = '
from(bucket: "PV-Daten")
|> range(start: -5s)
|> filter(fn: (r) => r["name"] == "'.$kunde.'")
|> filter(fn: (r) => r["_field"] == "'.$wert.'")
|> last()
';
$tables = $client->createQueryApi()->query($query, $org);
if (isset($tables[0])) {
$data = ($tables[0]);
$data = $data->records;
$data = ($data[0]);
return ($data->getValue());
} else {
return ("fail");
}
}