Last active
May 29, 2016 16:07
-
-
Save danielset/c337769795c6c68febe9ce30d9d0f9da to your computer and use it in GitHub Desktop.
API Connect cloudBit PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Place other API connects e.g. the one to Google here | |
// Your ID and token of your cloudBit | |
$deviceID = 'DEVICE_ID'; | |
$authToken = 'AUTH_TOKEN'; | |
// The data to send to the API | |
$cloudData = array( | |
'percent' => 80, | |
'duration_ms' => -1 | |
); | |
// Setup cURL | |
$ch = curl_init('https://api-http.littlebitscloud.cc/devices/'.$deviceID.'/output'); | |
curl_setopt_array($ch, array( | |
CURLOPT_POST => TRUE, | |
CURLOPT_RETURNTRANSFER => TRUE, | |
CURLOPT_HTTPHEADER => array( | |
'Authorization: Bearer '.$authToken, | |
'Content-Type: application/json' | |
), | |
CURLOPT_POSTFIELDS => json_encode($cloudData) | |
)); | |
// Send the request | |
$response = curl_exec($ch); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment