<?php

error_reporting(E_ALL);
ini_set('display_errors', '1');
require __DIR__ . '/bootstrap.php';
use Exception\ProtectimusApiException;
define("USERNAME", "");
define("API_KEY", "");
define("API_URL", "");
try {
    $api = new ProtectimusApi(USERNAME, API_KEY, API_URL);
    /*echo "<br/>CREATING A TOKEN<br/>";
    	$response = $api->addUnifyToken(null, null, "OATH_HOTP", "SHA1", "HEX", "unifytoken", "unifytoken",
                        "a08bc52465e75aa1d99dc19338ebf2e291467fe2", "123456", null, null, null, 8, null);
    	echo print_r($response, true) . "<br/>";*/
    echo "GETTING SECRET KEY FOR GOOGLE AUTHENTICATOR TOKEN<br/>";
    $response = $api->getGoogleAuthenticatorSecretKey();
    echo print_r($response, true) . "<br/>";
    $secret = $response->response->key;
    echo "SECRET KEY FOR GOOGLE AUTHENTICATOR TOKEN =>>> " . $secret . "<br/>";
    echo "<br/>GETTING SECRET KEY FOR PROTECTIMUS MOBILE TOKEN<br/>";
    $response = $api->getProtectimusSmartSecretKey();
    echo print_r($response, true) . "<br/>";
    $secret = $response->response->key;
    echo "SECRET KEY FOR PROTECTIMUS MOBILE TOKEN =>>> " . $secret . "<br/>";
    echo "<br/>CREATING A TOKEN<br/>";
    $response = $api->addSoftwareToken(null, null, "MAIL", "*****@*****.**", "Mail token", null, null, null, null, null, null);
    echo print_r($response, true) . "<br/>";
    $tokenId = $response->response->id;
    echo "ID OF THE CREATED TOKEN =>>> " . $tokenId . "<br/>";
    // to add hardware token you must own it, because you need to
<?php

error_reporting(E_ALL);
ini_set('display_errors', '1');
require __DIR__ . '/bootstrap.php';
use Exception\ProtectimusApiException;
define("USERNAME", "");
define("API_KEY", "");
define("API_URL", "");
try {
    $api = new ProtectimusApi(USERNAME, API_KEY, API_URL);
    echo "CREATING A RESOURCE<br/>";
    $response = $api->addResource("resource", 5);
    echo print_r($response, true) . "<br/>";
    $resourceId = $response->response->id;
    echo "ID OF THE CREATED RESOURCE =>>> " . $resourceId . "<br/>";
    echo "<br/>GETTING A RESOURCE BY ID<br/>";
    $response = $api->getResource($resourceId);
    echo print_r($response, true) . "<br/>";
    echo "RESOURCE =>>> " . print_r($response->response->resource, true) . "<br/>";
    echo "<br/>UPDATING A RESOURCE<br/>";
    $response = $api->editResource($resourceId, "resourceNew", 8);
    echo print_r($response, true) . "<br/>";
    echo "UPDATED RESOURCE =>>> " . print_r($response->response->resource, true) . "<br/>";
    echo "<br/>GETTING A LIST OF RESOURCES<br/>";
    // gets a list of resources descending (10 records starting from 'offset' parameter)
    $response = $api->getResources(0);
    echo print_r($response, true) . "<br/>";
    echo "RESOURCES =>>> " . print_r($response->response->resources, true) . "<br/>";
    echo "<br/>GETTING A QUANTITY OF RESOURCES<br/>";
    $response = $api->getResourcesQuantity();
 function protectimus_otp_authentication_request_handler($args = array())
 {
     try {
         $api = new ProtectimusApi($this->rcmail->config->get('protectimus_api_username'), $this->rcmail->config->get('protectimus_api_key'), $this->rcmail->config->get('protectimus_api_url'));
         $response = $api->authenticateUserToken($this->rcmail->config->get('protectimus_resource_id'), null, $this->rcmail->user->data['username'], $_POST['otp'], $_SERVER['REMOTE_ADDR']);
         if ($response->response->result) {
             $_SESSION[self::PROTECTIMUS_OTP_CHECK] = null;
             $_SESSION[self::PROTECTIMUS_CHALLENGE] = null;
             $this->rcmail->output->redirect(array('_task' => 'mail', 'action' => null));
         } else {
             $_SESSION[self::PROTECTIMUS_ERROR_MESSAGE] = $this->gettext('invalid_otp');
             $this->rcmail->output->redirect(array('_task' => null, 'action' => 'plugin.protectimus_otp_authentication'));
         }
     } catch (Exception $e) {
         $_SESSION[self::PROTECTIMUS_ERROR_MESSAGE] = $e->getMessage();
         $this->rcmail->output->redirect(array('_task' => null, 'action' => 'plugin.protectimus_otp_authentication'));
     }
 }
<?php

error_reporting(E_ALL);
ini_set('display_errors', '1');
require __DIR__ . '/bootstrap.php';
use Exception\ProtectimusApiException;
define("USERNAME", "");
define("API_KEY", "");
define("API_URL", "");
try {
    $api = new ProtectimusApi(USERNAME, API_KEY, API_URL);
    echo "CREATING A USER<br/>";
    $response = $api->addUser("login", "*****@*****.**", 12345678912, "pwd", null, null, true);
    echo print_r($response, true) . "<br/>";
    $userId = $response->response->id;
    echo "ID OF THE CREATED USER =>>> " . $userId . "<br/>";
    echo "<br/>GETTING A USER BY ID<br/>";
    $response = $api->getUser($userId);
    echo print_r($response, true) . "<br/>";
    echo "USER =>>> " . print_r($response->response->user, true) . "<br/>";
    echo "<br/>UPDATING A USER<br/>";
    $response = $api->editUser($userId, "loginNew", "*****@*****.**", 98765432112, null, null, null, false);
    echo print_r($response, true) . "<br/>";
    echo "UPDATED USER =>>> " . print_r($response->response->user, true) . "<br/>";
    echo "<br/>GETTING A LIST OF USERS<br/>";
    $response = $api->getUsers(0);
    echo print_r($response, true) . "<br/>";
    echo "USERS =>>> " . print_r($response->response->users, true) . "<br/>";
    echo "<br/>GETTING A QUANTITY OF USERS<br/>";
    $response = $api->getUsersQuantity();
    echo print_r($response, true) . "<br/>";