Dan Ruscoe's Personal Site

PHP Class for the Nabaztag API

A Nabaztag is a plastic rabbit that connects to your WiFi and reads out news stories and emails. It can also display weather information by lighting up and it moves its ears around from time to time. It comes with an API that's fun to tinker with.

Just for fun I've written a small PHP class to allow PHP applications to interface with the Nabaztag API.

Get the code on GitHub.

The example script demonstrates all the functionality, but for quick reference:

Create a new nabaztag object:
$nab = new Nabaztag($your_serial_number, $your_api_token);

Speak using text-to-speech:
$nab->speak("that rabbit's got a vicious streak a mile wide");

Move ears:
$nab->moveEars($left_ear_position, $right_ear_position);
Provide an integer between 0 and 16 to move the ears through their cycle.

Wake up or put to sleep:
$nab->setWakeStatus($status);
Passing a 1 to this function wakes the Nabaztag, 0 puts it to sleep.

The Nabaztag API will send a response to acknowlege a successful request or point out any errors made. The response is stored in the class and can be accessed via this function:
$nab->getLastApiResponse();

There is another diagnostic function that will list the parameters being send in an API request:
$nab->getApiParams();

Update: The company behind Nabaztag discontinued their website and API support in July of 2011. There is still an active community managing the API at the original domain, but full functionality hasn't yet been restored.