Skip to main content

WHMCS

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

One-click end-user login

The sp-enduser 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() like username and domain.

<?php
...
$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?'.$get, false, $context));
$link = $enduser.'session-transfer.php?session='.$session->session;

Fetching WHMCS information

You might want Halon or sp-enduser 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.

Here is an HSL 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);