<?php
$apiMonitor = DB::table('sites')->select('uptime_access_code')->get();
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.uptimerobot.com/v2/getMonitors",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "api_key=Private&format=json&logs=1&monitors=$apiMonitor&custom_uptime_ratios=1-7-30",
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache",
"content-type: application/x-www-form-urlencoded"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
$data = json_decode($response);
$custom_uptime = ($data->monitors[0]->custom_uptime_ratio);
$uptime = explode("-",$custom_uptime);
}
?>
I already get my value of my uptime access but its an array The thing is my monitor need only the value but when i dd() it this what happens.
This is my dd($apiMonitor);
The output I want to happen is
CURLOPT_POSTFIELDS => "api_key=Private&format=json&logs=1&monitors=778780885&custom_uptime_ratios=1-7-30",
The output that you can see is working already but how can I able to get the data from the database and put the value of uptime_access_code to my monitor? Thank you.
