rpaix helprpaix help

AIX.API

home/Documentation/AIX.API
Expand All Collapse All
  • Getting Started
  • Usage
  • Users
    • get-user
    • get-user-by
    • get-user-extra
    • get-user-language
    • get-users
  • Webhooks
    • message-sent
    • email-sent
    • sms-sent
    • new-messages-received
    • bot-message

Usage

28 views 0 August 23, 2023 Updated on October 16, 2023 rpaix-chat-team

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

PHP


function aix_api($query) {
    $ch = curl_init('YOUR-DOMAIN/script/include/api.php');
    $parameters = [
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_SSL_VERIFYPEER => false,
            CURLOPT_USERAGENT => 'AiX',
            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);
}


Usage example: aix_api(['function' => 'get-user', 'user_id' => 123]).

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/script/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 AiX installation. It should looks like this:  https://YOUR-DOMAIN/script/include/api.php.

Replace YOUR-TOKEN with the token of an admin user. You can get the token from AiX > 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:

Was this helpful?

Yes  No
Related Articles
  • bot-message
  • new-messages-received
  • sms-sent
  • email-sent
  • message-sent
  • Webhooks

Didn't find your answer? Contact Us

Previously
Getting Started
Up Next
Users
© 2023 rpaix.com. All Rights Reserved.