PHP

The PHP library is a single file with no dependencies. It is available for Windows, Linux, and macOS.

Installation

To use Flux, simply include the Flux.php file in your project.

require_once 'Flux.php';

Usage

Initialize Flux

To initialize Flux, create a new instance of the Flux class and pass your Application ID as a parameter.

$flux = new Flux("your_application_id");

Authenticate

To authenticate a user, call the authenticate() method with the user’s license key and an optional hardware ID.

try {
    $flux->authenticate("user_license_key", "optional_hardware_id");
    echo "Authentication successful.";
} catch (Exception $e) {
    echo "Authentication failed: " . $e->getMessage();
}

Get Field

To get a field from the authentication response, call the get_field() method with the name of the field.

try {
    $fieldValue = $flux->get_field("field_name");
    echo "Field value: " . $fieldValue;
} catch (Exception $e) {
    echo "Field not found: " . $e->getMessage();
}

Get Variable

To get the value of a variable, call the get_variable() method with the name of the variable.

try {
    $variableValue = $flux->get_variable("variable_name");
    echo "Variable value: " . $variableValue;
} catch (Exception $e) {
    echo "Error retrieving variable: " . $e->getMessage();
}

Download Variable

To download a variable as a file, call the download_variable() method with the name of the variable.

try {
    $fileContent = $flux->download_variable("variable_name");
    file_put_contents("output_file_name", $fileContent);
    echo "Variable downloaded successfully.";
} catch (Exception $e) {
    echo "Error downloading variable: " . $e->getMessage();
}