Table of Contents

Example API Usage

Internal API

GSP-Panel is coded using the same API that's available to you. For examples of how to use the API, view the source code for the files in the clients and admin folders. For definitions of what variables and functions do, please view our API Functions

A quick example of adding a user is below.

// The gsp-panel.php file is required for all internal calls
$api = true;
require_once("../includes/gsp-panel.php"); 
 
 
$params = array('email' => "apiuser@some_domain.com",
            'password' => "secretpassword");
 
// Call the AddClient function from the user class
$returnval = User::AddClient($params);

WebAPI v1.1

This is our new API that can be called internally or by POST/GET requests. Please review the documentation at WebAPI v1.1

   $data['apiversion'] = "1.1"; // Set the API version
   $data['apiusername'] = "[email protected]"; // Set the username (same as you would use to login)
   $data['apipassword'] = "yourpassword"; // Same password you use to login
   $data['action'] = "adduser"; // Function to call
   $data['email'] = "[email protected]"; // New users email
   $data['password'] = "secretpassword"; // Password for the new user
 
   $ch = curl_init();
   curl_setopt($ch, CURLOPT_URL, "http://127.0.0.1/api/webapi.php");
   curl_setopt($ch, CURLOPT_POST, 1);
   curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
   curl_setopt($ch, CURLOPT_TIMEOUT, 30);
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   $output = curl_exec($ch);
   curl_close($ch);
 
   echo $output; // Your output of the add user command

Legacy WebAPI

This is the first version of our WebAPI that can be called by using POST and GET requests to the api/webapi.php file. This API version is no longer supported and will not be updated in future versions. To see how to use this version of the API you can review api/webapi.php.