Helix:hCom
From HelixCore
The Helix Communications API (hCom) is a technical data recovery protocol for use on all PHP driven websites and applications, even those outside of Helix, which sends critical data to a Helix hCom server via XML. Data sent to hCom servers is stored discretely in a database and can not be accessed directly by any front of back-end.
By default, the hCom API sends all data to the Search IQ server, this can be reconfigured.
Usage
First off, ensure you have copied the API to the server, for new Helix distributions this will be in 'core/api/hcom/hcom.php'. Include the API when needed:
include_once('core/api/hcom/hcom.php');
When you have a successful transaction, send a log of the data before any possible fatal errors can occur, this typically would be done shortly before a 'mail()' command is executed.
$h = new hcom($site->siteName);
$h->addLead($_POST['name'], $_POST['email'], $message);
$h->send() || mail('jordon.s@searchiq.com.au', 'hCom error: '.$site->siteName, $h->error);
This sends a log with a name and e-mail taken from the POST data and a message body precompiled in the $message variable. The send() function of the hcom class returns false on failure, and the hcom::error variable contains the error message, so you can use the OR operator to output an error report or, in this example, send an e-mail to an administrator containing the error details.
You can call addLead() multiple times, each lead will be added to the XML feed and received by the server in order. Timestamps on the server are based on the servers receive time, all leads are marked with the variable passed to the hcom constructor.
