Download the latest version of KarotzPhp and add the Karotz
namespace
to your PSR-0 autoloading system, or simply require the autoload.php
{
"require": {
"karotz/karotz": ">=1.0.0-alpha"
}
}
use Karotz\Karotz;
$kz = new Karotz('Interactive ID');
try {
// Make flash your Karotz LED in red
$response = $kz->ledPulse('FF0000', 500, 500);
// Test the response
if ($response->getStatus())
echo "Rabbit flashs red light!";
else
echo $response->getCode().": ".$response->getDescription();
} catch(\Exception $e) {
echo $e->getMessage();
}
To run, the Karotz REST API needs an Interactive ID, which is reset every 15 minutes. Check the official documentation to know how retrieve this ID. http://dev.karotz.com/api/interactiveid.html KarotzPhp is not involved in managing the life cycle of the Interactive ID, but provides a way to get it with the signed START method:
use Karotz\Karotz;
$kz = new Karotz();
// Open a session and save the Interactive ID in the Karotz object
$response = $kz->start('install ID', 'API key', 'secret key');
Work in progress... waiting for some test
- Any flavor of PHP 5.3 should do
- Jeremy Perret jeremy@devster.org
- Thierry Geindre karotz@nostalgeek.org
KarotzPhp is licensed under the MIT License - see the LICENSE file for details