License Manager for WooCommerce

Easily sell and manage software license keys through your shop

Create a generator

Description

Creates a new generator. The response contains the newly created generator data object.

Request URL

POST/wp-json/lmfwc/v2/generators

Headers

Content-Type	application/json

Body

{
	"name": "Generator created by the API",
	"charset": "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
	"chunks": 5,
	"chunk_length": 5,
	"times_activated_max": 2,
	"separator": "-",
	"prefix": null,
	"suffix": null,
	"expires_in": null
}

Request Example (PHP)

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{host}}/wp-json/lmfwc/v2/generators?consumer_key={{consumer_key}}&consumer_secret={{consumer_secret}}",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => false,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS =>"{
	"name": "Generator created by the API",
	"charset": "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
	"chunks": 5,
	"chunk_length": 5,
	"times_activated_max": 2,
	"separator": "-",
	"prefix": null,
	"suffix": null,
	"expires_in": null
}",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
} ?>

Response

{
    "success": true,
    "data": {
        "id": "6",
        "name": "Generator created by the API",
        "charset": "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
        "chunks": "5",
        "chunkLength": "5",
        "timesActivatedMax": "2",
        "separator": "-",
        "prefix": null,
        "suffix": null,
        "expiresIn": null,
        "createdAt": "2019-09-04 20:28:46",
        "createdBy": "1",
        "updatedAt": null,
        "updatedBy": null
    }
}