Skip to content

Create a License

Michel edited this page Nov 5, 2024 · 1 revision

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.php is configured with your API URL and secret key.
  • Verify that LicenseAPI.php is 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

  1. Open CreateLicense.php.

  2. 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' => '[email protected]', '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

  1. Instantiate CreateLicense.

  2. Call the create() method with the $licenseData array. 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' => '[email protected]',
      '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: