This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
Creating a License
The CreateLicense.php file allows you to securely create a new license in your application by sending a request to the SLM Plus API. This guide explains how to configure and use CreateLicense.php to generate new licenses.
Prerequisites
- Ensure
CoreConfig.phpis configured with your API URL and secret key. - Verify that
LicenseAPI.phpis included in your project, as it contains the core method for creating licenses.
How to Use CreateLicense.php
Step 1: Set Up the License Data
-
Open
CreateLicense.php. -
Define the license data as an associative array with the necessary fields. Here’s an example of basic fields you may need:
$licenseData = [ 'first_name' => 'John', 'last_name' => 'Doe', 'email' => 'johndoe@example.com', 'purchase_id_' => '12345', // Unique ID for tracking the purchase 'max_allowed_domains' => 2, // Maximum number of domains for this license 'max_allowed_devices' => 1, // Maximum number of devices for this license 'date_created' => date('Y-m-d'), // License creation date 'product_ref' => 'YourProduct' // Reference name for the product ];
Adjust these fields as needed to match your product or user data.
Step 2: Call the create Method
-
Instantiate
CreateLicense. -
Call the
create()method with the$licenseDataarray. Here’s how:require_once 'CreateLicense.php';
$createLicense = new CreateLicense(); $createLicense->create($licenseData);
This sends a request to create the license using the SLM Plus API.
Step 3: Handle the Response
CreateLicense.php provides a response indicating the success or failure of the license creation. Here’s what to expect:
- Success: If the license is created successfully, you’ll see a message with the generated license key.
- Error: If there’s an issue (e.g., missing fields or invalid data), an error message will be displayed.
Example Usage
Below is a complete example of using CreateLicense.php to create a new license:
require_once 'CreateLicense.php';
$licenseData = [
'first_name' => 'John',
'last_name' => 'Doe',
'email' => 'johndoe@example.com',
'purchase_id_' => '12345',
'max_allowed_domains' => 2,
'max_allowed_devices' => 1,
'date_created' => date('Y-m-d'),
'product_ref' => 'YourProduct'
];
$createLicense = new CreateLicense();
$createLicense->create($licenseData);
Next Steps
Once you’ve configured and tested license creation, you can proceed to other actions:
Updated and maintained by Epikly