Difference between revisions of "WHMCS"

From Halon, SMTP software for hosting providers
Jump to: navigation, search
(Fetching WHMCS information)
 
Line 16: Line 16:
 
== Fetching WHMCS information ==
 
== Fetching WHMCS information ==
 
You might want the [http://wiki.halon.se email gateway] or [https://github.com/halonsecurity/sp-enduser end-user] control panel to fetch some information from the [https://developers.whmcs.com/api/sample-code/ WHMCS external API], such as iterating [https://developers.whmcs.com/api-reference/getclientsproducts GetClientsProducts]. We've done numerous such integrations, and can help you tailor the systems to fit perfectly.
 
You might want the [http://wiki.halon.se email gateway] or [https://github.com/halonsecurity/sp-enduser end-user] control panel to fetch some information from the [https://developers.whmcs.com/api/sample-code/ WHMCS external API], such as iterating [https://developers.whmcs.com/api-reference/getclientsproducts 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 [https://developers.whmcs.com/api/sample-code/ WHMCS external API] from [[HSL]].
 +
 +
<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);
 +
</hsl>

Latest revision as of 08:33, 4 August 2017

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 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.

<?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?'.$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);