Download the PHP package skpassegna/old-freemius-php-sdk without Composer
On this page you can find all versions of the php package skpassegna/old-freemius-php-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download skpassegna/old-freemius-php-sdk
More information about skpassegna/old-freemius-php-sdk
Files in skpassegna/old-freemius-php-sdk
Package old-freemius-php-sdk
Short Description Freemius PHP SDK (PSR-4 autoloading compatible)
License GPL-2.0+
Homepage https://github.com/skpassegna/old-freemius-php-sdk
Informations about the package old-freemius-php-sdk
Freemius PHP SDK
This SDK provides a PHP interface for interacting with the Freemius API from your own server-side applications or scripts. It handles authentication, request signing, and response parsing, enabling you to access and manage your Freemius account data, user information, plugin/theme installations, licenses, payments, and more – all from outside of your WordPress plugin or theme.
Note: A new, improved SDK is currently under development (by @skpassegna).
This SDK is particularly useful for building custom dashboards, reporting tools, integration with other services, or performing administrative tasks related to your Freemius products. It is not intended for use within your WordPress plugins or themes themselves; that's the role of the Freemius WordPress SDK.
Installation
Use Composer to install the SDK:
Usage
Here's a basic example demonstrating how to retrieve your plugin's information:
Authentication
The SDK handles authentication automatically. You provide your public and secret keys during initialization. The SDK uses a signature-based authentication method, generating a unique signature for each API request to ensure security.
Scopes
The $scope
parameter is critical and determines the context of your API interactions. It specifies which Freemius entity the SDK will operate on and dictates which API endpoints are accessible. Here's a summary of common scopes:
Scope | Description | ID Used |
---|---|---|
plugin |
Access data for a specific plugin. | Plugin ID |
developer |
Access data across all plugins under your developer account. | Developer ID |
install |
Access data for a single plugin installation on a website. | Installation ID |
user |
Access data related to a specific Freemius user. | User ID |
app |
Access app level data | App ID |
API Calls
The Api()
method is the primary way to interact with the Freemius API:
$endpoint
: The API endpoint path relative to the base path determined by the scope. For example,/plugins.json
(to list plugins under a developer account – developer scope),/.json
(to get the current plugin's information - plugin scope), or/installs.json
(to list installs of a plugin - plugin scope).$method
: The HTTP method (e.g.,'GET'
,'POST'
,'PUT'
,'DELETE'
). Defaults to 'GET'.$params
: An associative array of parameters for the request (e.g., query parameters or JSON data for POST requests). For multipart requests (file uploads), include any extra JSON data under the 'data' key as a JSON encoded string.$fileParams
: An associative array for multipart form uploads (e.g. plugin deployments). The key is the field name (e.g., 'file'), and the value is the file path.
The Api()
method returns the decoded JSON response from the Freemius API or the raw response if decoding fails. The Freemius API primarily uses JSON for data exchange.
Signed URLs
Generate secure, time-limited URLs for accessing protected resources:
Signed URLs are useful for scenarios where you need to provide direct access to a resource without sharing your secret key.
Sandbox Mode
Test your integration without affecting live data by enabling sandbox mode:
Make sure to use your sandbox API credentials when testing in sandbox mode.
Error Handling
The SDK may throw exceptions during API interactions. Proper error handling is essential:
Key API Endpoints and Examples
Here's a summary with examples to help you get started:
Plugin Scope:
- Get Plugin Details:
$fs->Api('/.json')
- Get Latest Version Info:
$fs->Api('/updates/latest.json')
- Deploy New Version (Simple):
$fs->Api('/plugins/YOUR_PLUGIN_ID/tags.json', 'POST', [], ['file' => './my-plugin.zip'])
- Deploy New Version (With Additional Data):
$fs->Api('/plugins/YOUR_PLUGIN_ID/tags.json', 'POST', ['data' => json_encode(['add_contributor' => true])], ['file' => './my-plugin.zip'])
- Deploy New Version (With Release Mode):
$fs->Api('/plugins/YOUR_PLUGIN_ID/tags.json', 'POST', ['data' => json_encode(['release_mode' => 'released'])], ['file' => './my-plugin.zip'])
Developer Scope:
- Get all Plugins:
$fs->Api('/plugins.json')
- Get all Installs of a Plugin:
$fs->Api('/plugins/{plugin_id}/installs.json')
(Replace{plugin_id}
with the actual ID) - Create a Developer: $fs->Api('/apps/YOUR_APP_ID/developers.json', 'POST', $developerData);
- Get Developer's billing information: $fs->Api('/developers/YOUR_DEV_ID/billing.json', 'GET');
- Get Developer's balance: $fs->Api('/apps/YOUR_APP_ID/developers/YOUR_DEV_ID/balance.json', 'GET');
Install Scope:
- Get Install Details:
$fs->Api('/.json')
- Start a Trial (for a plan):
$fs->Api('/plans/{plan_id}/trials.json', 'POST')
(Replace{plan_id}
with the actual ID) - Deactivate an Install's License:
$fs->Api('/licenses/{license_id}.json', 'DELETE')
(Replace{license_id}
with the actual ID) - Retrieve an install's uninstall details :
$fs->Api('/uninstall.json', 'GET')
- Get install's plan:
$fs->Api('/plans.json', 'GET')
User Scope:
- Get User Details:
$fs->Api('/.json')
- Get User's Installs of a Plugin:
$fs->Api('/plugins/{plugin_id}/installs.json')
(Replace{plugin_id}
with the actual ID) - Sync User with Freemius:
$fs->Api('/plugins/{YOUR_PLUGIN_ID}/users/{user_id}.json', 'PUT', $userData)
Remember to replace placeholders like YOUR_PLUGIN_ID
, YOUR_APP_ID
,YOUR_DEV_ID
, pk_YOUR_PUBLIC_KEY
, and sk_YOUR_SECRET_KEY
with your actual values. Consult the Freemius API documentation for details on request parameters and response formats.
License
GPL-2.0+