Forked from vovafeldman/freemius-api-license-validation.php
Created
March 6, 2022 14:55
-
-
Save lkoudal/18b493c372cb9d3dd1ac7be7523b692b to your computer and use it in GitHub Desktop.
Validates a license key using Freemius API using the PHP SDK
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Freemius PHP SDK - https://github.com/Freemius/freemius-php-sdk | |
require_once './php-sdk-master/freemius/Freemius.php'; | |
define( 'FS__API_SCOPE', 'developer' ); | |
define( 'FS__API_DEV_ID', 1234 ); | |
define( 'FS__API_PUBLIC_KEY', 'pk_YOUR_PUBLIC_KEY' ); | |
define( 'FS__API_SECRET_KEY', 'sk_YOUR_SECRET_KEY' ); | |
// Init SDK. | |
$api = new Freemius_Api(FS__API_SCOPE, FS__API_DEV_ID, FS__API_PUBLIC_KEY, FS__API_SECRET_KEY); | |
$licenses = $api->Api("/plugins/{$plugin_id}/licenses.json?search=" . urlencode($validated_license_key)); | |
$is_valid_license_key = (1 === count($licenses->licenses)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment