Forked from vovafeldman/freemius-api-license-validation.php
Created
October 2, 2024 11:04
-
-
Save andreiglingeanu/ee20f71605a783465e064e6262c8af61 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