From Halon, SMTP software for hosting providers
Jump to: navigation, search

We've done a couple of different integration with the automation solution WHMCS and the Halon SMTP software; communication going in both directions.

One-click end-user login

The end-user control panel supports on-the-fly (session-based) access levels (domain or email based), which a WHMCS module can prepare via the session-transfer.php file. The username and domain can be obtained in different ways; one way is to use an existing module which already defines $smarty->get_template_vars()s like username and domain.

$get http_build_query(array('username' => $username'api-key' => $apikey));
$access http_build_query(array('access' => array('domain' => $domains)));
$opts = array('http' => array('method'  => 'POST''header'  => 'Content-type: application/x-www-form-urlencoded''content' => $access));
$context stream_context_create($opts);
$session json_decode(@file_get_contents($enduser.'session-transfer.php?'.$getfalse$context));
$link $enduser.'session-transfer.php?session='.$session->session

Fetching WHMCS information

You might want the email gateway or end-user control panel to fetch some information from the WHMCS external API, such as iterating GetClientsProducts. We've done numerous such integrations, and can help you tailor the systems to fit perfectly.

Example code

Here is an example on how you can connect to the WHMCS external API from HSL.

$whmcsUrl "https://www.yourdomain.com/path/to/whmcs/";

// WHMCS >= 7.2
$username "your_api_credential_identifier";
$password "your_api_credential_secret";

// WHMCS < 7.2
// $username = "your_username";
// $password = md5("your_password");

$postfields = [
"username" => $username,
"password" => $password,
"action" => "GetClients",
"responsetype" => "json",

$response http($apiurl."includes/api.php", ["ssl_default_ca" => true], [], $postfields);
$jsonData json_decode($response);