-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlicense-validation-example.php
More file actions
45 lines (36 loc) · 1.16 KB
/
license-validation-example.php
File metadata and controls
45 lines (36 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
error_reporting(E_ALL ^ (E_NOTICE | E_WARNING | E_DEPRECATED));
// Load Composer Dependencies
require __DIR__ . "/vendor/autoload.php";
// Autoload Requests library internal classes
Requests::register_autoloader();
// The license key domain and license key you want to
// validate.
$licenseKey = $argv[1];
$domain = $argv[2];
// Print out some information.
print("Program initialized with these values:\n");
print_r(array(
"License Key" => $licenseKey,
"Domain" => $domain
));
// First, let"s see if the customer already exists.
$validateUrl = "https://kernl.us/api/v2/public/license/validate-with-domain";
$validateQueryString = "?license=$licenseKey&domain=$domain";
$response = Requests::get($validateUrl.$validateQueryString);
$responseData = json_decode($response->body);
// License exists and is valid.
if($response->status_code == 200) {
echo "\n{$responseData->message} \n";
}
// License exists but is not valid.
if($response->status_code == 403) {
echo "\n{$responseData->err} \n";
}
// License does not exist
if($response->status_code == 404) {
echo "\n{$responseData->err} \n";
}
echo "Full response JSON object:\n";
print_r($responseData);
?>