Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lkoudal/18b493c372cb9d3dd1ac7be7523b692b to your computer and use it in GitHub Desktop.
Save lkoudal/18b493c372cb9d3dd1ac7be7523b692b to your computer and use it in GitHub Desktop.
Validates a license key using Freemius API using the PHP SDK
<?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