I trying to convert the cURL code found here in the first example code. Here is the cURL they give me:
curl -X GET -H "Content-type: application/json" -d '{"api_key":"zUYwqLqwTqpyJ2bA7osy"}' https://statushub.io/api/status_pages
Here is what I have so far, and it isn't working:
<?php
#$cmd= 'curl -X GET -H "Content-type: application/json" -d \'{"api_key":"a991d51f4f7ea269ccfbfa68621b3aa3"}\' https://statushub.io/api/status_pages';
#exec($cmd,$result);
#echo gettype($result), "\n";
#echo print_r(curl_exec($cmd));
$ch = curl_init('https://statushub.io/api/status_pages');
curl_setopt($ch, CURLOPT_HTTPHEADER, 'Content-type: application/json');
curl_setopt($ch, CURLOPT_POSTFIELDS, '{"api_key":"a991d51f4f7ea269ccfbfa68621b3aa3"}');
#curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$test = curl_exec($ch);
curl_close($ch);
echo (string)$test;
if(curl_exec($ch) === false)
{
echo 'Curl error: ' . curl_error($ch);
}
else
{
echo 'Operation completed without any errors';
}
echo "<pre>";
print_r($test);
echo "</pre>";
?>
I included some other attempts with lines coded out. I have tried looking at the php cURL documentation, but I can't figured this one out.
Thanks in advance.