Skip to content

API knowledge base

Setup and usage

Our WEB API, JAVASCRIPT API or PHP provides a collection of methods that underpin most of Bechat Cloud's functions. To get started using the Web API, follow the tutorial below.

WEB API

Usage

Make a POST call to the file include/api.php of your Support Board installation. You can use the following code to make the calls:

PHP function support_board_api($query) {
    $ch = curl_init('YOUR-DOMAIN/supportboard/include/api.php');
    $parameters = [
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_SSL_VERIFYPEER => false,
            CURLOPT_USERAGENT => 'Support Board',
            CURLOPT_POST => true,
            CURLOPT_CONNECTTIMEOUT => 5,
            CURLOPT_POSTFIELDS => http_build_query(array_merge(['token' => 'YOUR-TOKEN'], $query))
    ];
    curl_setopt_array($ch, $parameters); 
    $response = curl_exec($ch);
    curl_close($ch);
    return json_decode($response, true);
}
JQUERY Warning! This function is not secure because .js files are accessible by anyone. Make sure this code is only available to the correct user.
$.post('YOUR-DOMAIN/supportboard/include/api.php', {
    function: 'METHOD-NAME',
    token: 'YOUR-TOKEN'
}, function (response) {
    response = JSON.parse(response);
    if (response.success) {
    }
});
The variable $response will contains the JSON response. You can add new arguments in the query array: ['token' => '', 'function' => '', 'argument-name' => 'value', ...].

 


Replace the following strings with the correct values:

Replace YOUR-DOMAIN with the URL of your website. The full URL must point to the file include/api.php of your Support Board installation. It should looks like this: https://bechat.cloud//supportboard/include/api.php (if you're using the WordPress version: https://bechat.cloud/wp-content/plugins/supportboard/supportboard/include/api.php. If you're using the cloud version: https://bechat.cloud/script/include/api.php).

Replace YOUR-TOKEN with the token of an admin user. You can get the token from the Users area by opening the profile box of an admin user. Only admin tokens are supported and only the admins can view the tokens. If you're using the cloud version you have to use the token from Account > Installation > API token.
Warning! This token must be kept always secret.

Replace METHOD-NAME with the name of the API function you want to use. Get them from the methods list below.

Information
Some functions are protected for security reasons, enter the code $GLOBALS['SB_FORCE_ADMIN'] = true before calling the function to execute it correctly. Enter the code $GLOBALS['SB_FORCE_ADMIN'] = false immedidately after the function call for security reasons.

Some functions require the user details of the active user, use the code $GLOBALS['SB_LOGIN'] = ['id' => '', 'first_name' => '', 'last_name' => '', 'email' => '', 'user_type' => '', 'department' => '']; to set the active user.


Postman example: 
postman

 

Users

Methods to manage users, agents, and admins.

get-user

Returns the user details of a user.

 

 

 

JAVASCRIPT API

PHP API

USE CASES