Services_NabaztagServices_Nabaztag
The Nabaztag object is used to communicate with the Nabaztag. You only have to create this object once; you can use it for many requests. Use your Nabaztag serial number and API token when creating the object. You can get your API token at http://www.nabaztag.com/
Example:
Located in /Nabaztag.php (line 87)
Services_Nabaztag
__construct
([string $serial = null], [string $token = null], [string $idApp = null])
boolean
say
(string $message, [string $voice = false], [float $speed = false], [integer $ttl = false], [float $pitch = false])
array
$apiErrorMessages
= array(Array of regexps that, when received from the API in the MESSAGE tag, signify an error from Nabaztag.com's servers.
array
$apiSuccessMessages
= array(Associative array of parameter => regexp. When we send the parameter, we expect the regexp in the MESSAGE tag. If it is not received, we assume that the command has been unsuccessful.
string
$apiURL
= "http://api.nabaztag.com/vl/FR/api.jsp" (line 134)
Default URL for Nabaztag.com API. This has changed in Nabaztag API 2.0.
boolean
$debug
= false (line 241)
True if setDebug() has been called; we will echo debug information when doing an API request.
string
$defaultPitch
= 1 (line 127)
Default pitch for Text-To-Speech messages created with say(). As of 2006-12-27, this does not seem to alter the pitch but instead alters the speed.
float
$defaultSpeed
= 1 (line 109)
Default speed for Text-To-Speech messages created with say(). Higher is faster. A speed of 1 is normal, 0.5 is half speed, 2 is double speed.
integer
$defaultTTL
= 3600 (line 101)
Default time-to-live (TTL) of the Text-To-Speech messages created with say(), in seconds. After this time, the messages are automatically deleted from the Nabaztag owner's web interface.
string
$defaultVoice
= "" (line 118)
Default voice for Text-To-Speech messages created with say(). According to Nabaztag.com's documentation, voice "heather22k" is used for English rabbits and voice "claire22s" for French rabbits.
string
$error
= null (line 207)
Message from the last error.
string
$idApp
= null (line 200)
API "idapp" number. Reserved for future use by Nabaztag.com API. These numbers might be given out by nabaztag.com to specific users.
boolean
$inTransaction
= false (line 214)
True whenever we are in a transaction started with startTransaction().
array
$request
= array() (line 225)
Cache of all the requests that we will send to the Nabaztag API in transaction mode.
This is an associative array of parameter => value. All these parameters and values are appended to the URL when Nabaztag.com is contacted.
string
$response
= null (line 233)
Cache of the response. We set this in apiRequest(), but we could use it later, for instance in getEars() and for debugging.
string
$serial
= null (line 185)
Serial number of the Nabaztag rabbit (equal to the MAC address without the ":" characters).
string
$token
= null (line 192)
API token of the Nabaztag rabbit (get this at http://www.nabaztag.com/)
Constructor __construct (line 459)
Constructs a Nabaztag control object for users with a Nabaztag.com "idapp" number.
The Nabaztag object is used to communicate with the Nabaztag. You only have to create this object once; you can use it for many requests. Use your Nabaztag serial number and API token when creating the object. You can get your API token at http://www.nabaztag.com/
As the third argument of the constructor, you can optionally specify an "idapp" number for your application. This seems to be a future Nabaztag.com parameter. As of 2006-12-27, you can omit this argument.
Example:
apiRequest (line 274)
Perform a single API call to Nabaztag.com.
This call is made whenever a transaction is carried out with commitTransaction() or whenever a command such as say() is issued directly.
Throws Services_Nabaztag_Exception whenever a fatal error is encountered. This can either be a communication error (e.g. Nabaztag server down), or an error from Nabaztag.com (invalid serial number, invalid input, et cetera).
apiRequestSave (line 420)
Saves the currently buffered transaction requests, performs a request $request, and restores the current transaction.
Note: This function preempts any possible running transactions by saving the old request state ($this->request) and restoring it afterwards. It is used for getting status information (requiring a call to the API) while the user is currently busy filling a transaction.
commitTransaction (line 578)
End a transaction and send the pending commands to the Nabaztag.
The Nabaztag class can combine multiple commands (like say()) in one API request. Using this will save HTTP calls and processing time on Nabaztag's servers.
To use this, simply group your commands between $nabaztag->startTransaction() and $nabaztag->commitTransaction(). If you do this, you MUST always end with a commitTransaction().
Example:
dance (line 608)
Send a dance ("choreography") to the Nabaztag, changing the LEDs and ears of the Nabaztag in a specified pattern.
For a description of the choreography format, please refer to the Nabaztag API documentation at: http://www.nabaztag.com/vl/FR/gfx/2/Documentation%20API-revA001_uk.pdf
Example:
getBlackList (line 1046)
Returns a list of blacklisted rabbits for this rabbit.
getEars (line 822)
Get the current position of the Nabaztag's left and right ear.
Will return an associative array of the left and right values, which are integers in the range 0-16.
Please see the documentation on setEars() for more information about position values.
Example:
getError (line 500)
Provides a descriptive error message in case a problem has occurred.
If an error has occurred (signified by a 'false' result from a function), you can retrieve a descriptive error message by calling getError().
Note that the Nabaztag class now uses exceptions as well. On every error, a Services_Nabaztag_Exception is thrown. You can also read the message from the exception.
Example:
getFriendList (line 1028)
Returns a list of the friend names for this rabbit.
getInbox (line 1010)
Returns the messages in the inbox.
Example:
Example output: Message from Slartibartfast, today 01:27:13 with title Testing! and url broad/001/154/461/401.mp3
getName (line 911)
Returns the configured name of the rabbit.
getSelectedLanguages (line 1064)
Returns the current list of selected languages for the rabbit.
getSignature (line 943)
Returns the configured signature of the rabbit which will be added to text messages sent through the API.
This is a string in the form "cdll=long,3,none,broad/config/signature/HarpeGlisse.mp3, 0,7,0,led,4,255,0,255,1,led,4,0,0,0,2,led,4,255,0,255,3,led,4,0,0,0,4,led,4,255,0,255, 5,led,4,0,0,0,6,led,4,255,0,255,7,led,4,0,0,0,8,led,4,255,0,255,9,led,4,0,0,0,10,led, 4,255,0,255,11,led,4,0,0,0" (without newlines or spaces).
getTimeZone (line 924)
Returns the configured timezone of the rabbit.
getVersion (line 898)
Returns the version string of the rabbit, which determines if the rabbit is a Nabaztag ("V1") or a Nabaztag/tag ("V2").
getVoices (line 858)
Returns an associative array of allowed voices => languages that are recognized by Nabaztag.com API.
One of these voices can be supplied as the second parameter to say().
Example:
initialized (line 511)
Returns true if and only if the Nabaztag object has been constructed correctly with Nabaztag serial number and token.
isSleeping (line 883)
Checks if the rabbit is sleeping.
Sleep times can be defined in the nabaztag.com control panel. The rabbit can also sleep when sleep() is called.
playMessage (line 716)
Let the Nabaztag play back a stored message with a certain messageId.
The messageId is the number of the message on Nabaztag.com. The messageId can refer to one of the messages in the library, or an mp3 file that was uploaded to my.nabaztag.com.
Example:
recordNabcast (line 746)
Create a Nabcast from the text message sent.
Currently, this can only be used from within a transaction. All the say() commands during the transaction will be sent as the Nabcast.
Example:
say (line 643)
Send a text to the Nabaztag, which will be spoken using Text-To-Speech.
Possible languages for the Text-To-Speech are English and French, depending on the language chosen by the Nabaztag API user on the nabaztag.com site.
Example:
setDebug (line 479)
Enable debug mode, in which extra output is printed about the request and response.
Note: Using debug mode could print sensitive output. Don't use this on a public website.
Example:
setEars (line 786)
Set the position of the Nabaztag's ears.
The position is specified by two integers (left ear and right ear) in the range 0-16.
Note: The same numbers of the left and right position do not seem to correspond to the same physical ear directions. On the author's Nabaztag, for instance, calling $nabaztag->setEars(8, 0) will move both ears fully into the "up" position, while $nabaztag->setEars(12,4) moves both ears forward. According to the Nabaztag.com documentation (0, 0) is "ear horizontal".
Comments and experiences with setting ear positions are welcome. After gathering more experiences, perhaps a symbolic input like $nabaztag->setEars("up", "up") could be considered for a future version.
Example:
setError (line 250)
Set the error value. This throws a Services_Nabaztag_Exception.
You can retrieve the error value later with getError().
setSleep (line 958)
Sets the sleep state of the rabbit.
sleep (line 977)
Lets the rabbit sleep.
Same as $nabaztag->setSleep(true).
startTransaction (line 545)
Start a transaction (batch for multiple commands).
The Nabaztag class can combine multiple commands (like say()) in one API request. Using this will save HTTP calls and processing time on Nabaztag's servers.
To use this, simply group your commands between $nabaztag->startTransaction() and $nabaztag->commitTransaction(). If you do this, you MUST always end with a commitTransaction().
Note 1: All say() commands in one transaction use the same speed and voice. The first speed or voice parameters will be saved and used for all say() commands.
Note 2: You can only use one dance() in a transaction; these commands can not be combined.
Example:
wakeUp (line 990)
Lets the rabbit wake up from sleep.
Same as $nabaztag->setSleep(false).
Documentation generated on Mon, 07 Apr 2008 01:56:33 +0200 by phpDocumentor 1.4.1