I am trying to make an API call to Influx db from PHP program. The curl request to be made is -
curl -G 'http://localhost:8086/query?pretty=true' --data-urlencode "q=SHOW MEASUREMENTS"
The code in PHP that I am stuck with is -
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "http://localhost:8086/query?pretty=true",
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache"
),
));
I am not sure in which curl_setopt_array should I send the q=SHOW MEASUREMENTS
$query = urlencode("SHOW MEASUREMENTS");
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "http://localhost:8086/query?pretty=true&q=" . $query,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache"
),
));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With