BillingFox Hooks

Hooks are used as "Reverse APIs", so you can create your own API for your BillingFox installation.

Choose a documentation section.

Hooks can be used in many situations such as "order APIs" or "login with (your BillingFox website name)" buttons and more.

You should use define('HOOK_CALL', true); to define the hook.

You should make the database connection again (example in the "Code examples" section) in order to use your database.

You should include the hooks special functions from /install/hooks_func.php.

Copy to clipboard
// Create a simple hook: <?php /** * THOS-SOFTWARES LTD. - ALL RIGHTS RESERVED. * BillingFox example hook file. * Hooks are a way to create your own API(s) linked to your BillingFox installation. * @author THOS-SOFTWARES LTD. * @package BillingFox * @link https://billingfox.net **/ die('This hook call is used only for example purposes.'); // Don't let this hook be accessed. define('HOOK_CALL', true); // Make BillingFox know that this file is a hook, without defining HOOK_CALL hooks_func.php cannot be accessed. if(file_exists('../install/config.inc.php')) // Check if BillingFox is installed. { include('../install/config.inc.php'); $db = mysqli_connect($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME, $DB_PORT); // Connect to database. if(!$db) { die(json_encode(array('status' => 'ERROR', 'answer' => 'The API hook could not connect to database.'))); // Throw an error in JSON format if the hook cannot connect to database. } if(file_exists('../install/hooks_func.php')) // Check if hooks base functions file is existing. { include('../install/hooks_func.php'); // Include hooks base functions file. die(json_encode(array('status' => 'OK', 'answer' => 'The API hook is working.'))); // If the hook ran succesfully, trow an 'OK' status message in JSON format, the status can be anything. } else { die(json_encode(array('status' => 'ERROR', 'answer' => 'The API hook could not connect to database.'))); // Throw an error in JSON format if the hook cannot find hooks base functions file. } } ?>