I am fiddling with the HTTP API trying to toggle my lights from a PHP script. Here is my code:
header('Content-Type: application/json'); $lampid = $_POST['lampid']; // our lampid looks like this: d073d5107598 $token = $_POST['token']; // our API token $link = "https://api.lifx.com/v1/lights/".$lampid."/toggle"; $ch = curl_init($link); $headers = array('Authorization: Bearer ' . $token); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_exec($ch);
All I am getting back from this is a simple JSON object:
I am thinking that this is an issue with my token/lamp id mismatching, but I have run the same setup through the API example on this page: http://api.developer.lifx.com/docs/toggle-power and I can toggle my lights no worries. That page returns the API link which I have checked against my own PHP generated link and it is the same. I know my API token is correct because this method is being called straight after a successful ‘list’ request using the same credentials.
What am I missing?