Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagephp
<?php
require_once ('/path/to/modules/addons/nocpsforwhmcs/autoload.php');

$handler = new nocps_Handler ($pid, 'pid'); // replace $pid with tblhosting.id
// OR: $handler = new nocps_Handler ($serverId, 'serverId'); // replace $serverId with tblservers.id
$NocpsLoginDetails$nocpsLoginDetails = $handler->getInstance()->login; // Contains the NOC-PS login details and server id. Usually you don't need this.
$api = $handler->getInstance()->api;

// https://www.noc-ps.com/downloads/PXE_API.html
// Execute API call like:
// $api->getAvailableBandwidthData($mac);

...

By default, this class caches the most responses from NOC-PS. The cache is seperated per WHMCS server id, means if you have 2 NOC-PS servers, the module will create a dedicated cache for each serverNOC-PS backend.
To disable the cache, you can use the following method to disable the cache for all queries from the same instance:

...

You can set this in the code at any time, even before creating the class instance.

Please note that an exception will be thrown if an API error occurs. Own code should therefore be packed in try / catch.