Http api response is blank

Hi All,

As far as I understood, when I try to use http api using this code block:
$link = “”;
$authToken = “XXXX”;
$ch = curl_init($link);
$headers = array('Authorization: Bearer ’ . $authToken);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
it should response relevant info for listing lights. But somehow I dont get the response, although the status is 200.

I am quiet sure the bulb is proper on the cloud, since if I use the tool on the page:

it returns properly.

What may I be missing?

Instead of storing the response in a variable try letting the curl_exec() function print it’s own info to the page. I seem to remember having a similar problem, but I’m not sure if this is all I did to fix it.

1 Like

Thanks for your reply, it did not solve it wholly but led to the solution :slightly_smiling:
For anyone experiencing same issue, adding this header:
fixed my problem, now I can properly list lights.

WHOA! If you do that you are essentially saying that you don’t care about SSL security at all! That is a very bad thing.

Look in your error logs for the reason why libcurl is rejecting the SSL certificate for the server. Most likely you have an out of date version of the CA database. You can get a new version of the libcurl certificate database here and install it by following steps that came with your PHP distribution.


Yes! Anyone unfamiliar with the issue should read this.

Thanks for your response.

Indeed that was the reason why it was not working, after downloading that certificate and adding:
curl_setopt($ch, CURLOPT_CAINFO, dirname(DIR).’/php/cacert.pem.txt’);
fixed the issue for me.