SmartBots PHP API
Getting Started
Before following these instructions, please download the source files and place them into your project.
To begin, you will first need to create a blank .php file and include the 'smartbots_api.php' file.
<?php
include("smartbots_api.php"); // Include the SmartBots API file.
Next, we will need to define your SmartBots Developer API key, your bot's name and access code so that it's easier to use them later.
$apiKey = "e40e365171a99nl05bdmd697273b573t"; // SmartBots API Key.
$botName = "Example Resident"; // The bot's full name.
$botAccessCode = "KbYpnfa"; // The bot's access code.
If you're not familiar with Object-Orientated PHP, the next section may look a little strange, however follow the instructions and all should be clear.
Now we will create the $bot
variable and instansiate a new SmartBot() class
so that we can begin making our bot function.
$bot = new SmartBot(); // Instansiate a new SmartBot class.
To let the SmartBots API know what bot we are going to be controlling, we now need to use the setup()
method/function to enter in the variables we created earlier. The setup process returns TRUE
or FALSE
, depending on whether or not it was successful, meaning that you would use it within an 'if' statement if you wanted.
$bot->setup($apiKey, $botName, $botAccessCode); // Pass the setup variables to the API.