This C++ library allows you to interact with the Flux API for user authentication and variable fetching.
The C++ library is available as a static library for Windows, Linux, and macOS. You can download the library from the resources page. To use the library, you will need to link it to your project and include the header file.
To initialize the library, you need to set the application ID using the set_application
method.
bool success = flux::set_application("your_application_id");
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");
std::cout << "Authentication successful." << std::endl;
} catch (std::runtime_error& e) {
std::cout << "Authentication failed: " << e.what() << std::endl;
}
To get a field from the authentication response, use the field::get
method with the desired field name.
try {
std::string field_value = flux::field::get<std::string>("field_name");
std::cout << "Field value: " << field_value << std::endl;
} catch (std::runtime_error& e) {
std::cout << "Error getting field: " << e.what() << std::endl;
}
To get a variable value from the server, use the variables::get
method with the desired variable name.
try {
std::string variable_value = flux::variables::get<std::string>("variable_name");
std::cout << "Variable value: " << variable_value << std::endl;
} catch (std::runtime_error& e) {
std::cout << "Error getting variable: " << e.what() << std::endl;
}
To download a file from the server, use the variables::download
method with the desired file name.
std::vector<char> data;
try {
flux::variables::download("file_name", data);
std::cout << "File downloaded successfully." << std::endl;
} catch (std::runtime_error& e) {
std::cout << "Error downloading file: " << e.what() << std::endl;
}
After downloading the file, the data will be stored in the data
vector which can be used to save the file or process the data further as needed.