PHP code example of spectrumvoip / netsapiensclient

1. Go to this page and download the library: Download spectrumvoip/netsapiensclient library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

spectrumvoip / netsapiensclient example snippets




$nsclient = new \spectrumvoip\NetSapiensClient\NetSapiensClient('your-hostname.com');

$nsclient->login($clientId, $clientSecret, $username, $password);

$params = [
    'format' => 'json',
    'object' => 'domain',
    'action' => 'count',
    'domain' => '*'
];

try {
    $response = $nsclient->ns_api_get($params);
    echo "Number of domains: " . $response['total'];
} catch (Exception $e) {
    echo "Error: " . $e->getMessage();
}

$params = [
    'format' => 'json',
    'object' => 'user',
    'action' => 'create',
    // Add other necessary parameters
];

try {
    $response = $nsclient->ns_api_post($params);
    echo "User created successfully";
} catch (Exception $e) {
    echo "Error: " . $e->getMessage();
}

$masqueradeResponse = $nsclient->masquerade_token($uid, $accessToken);