PHP SDK #
Platform-agnostic PHP class for communicating with the Update Server API.
File #
sdk/php/class-dmsi-update-client.php
Requirements #
- PHP 7.4+
- curl PHP extension
Basic Usage #
require_once 'class-dmsi-update-client.php';
$client = new DMSI_Update_Client([
'api_url' => 'https://yoursite.com',
'product_id' => 42,
]);
// Check for an update
$result = $client->check_update('XXXX-XXXX-XXXX-XXXX', '1.0.0', [
'channel' => 'stable',
]);
if ($result && $result['update_available']) {
echo "Update available: " . $result['version'];
// $result['download_url'] contains the signed download URL
}
Available Methods #
| Method | Description |
|---|---|
check_update($license_key, $current_version, $options) | Check for available update |
get_version_info($license_key, $version) | Get metadata for a specific version |
list_versions($license_key, $channel) | List all available versions |
get_status() | Server health check (no license key needed) |
activate_license($license_key, $site_url, $site_name) | Activate a license |
deactivate_license($license_key, $activation_id) | Deactivate a license |
validate_license($license_key, $site_url) | Validate license status |
download($url, $destination, $expected_hash) | Download file and verify hash |
get_last_error() | Get the last error message and code |
Constructor Configuration #
| Option | Required | Description |
|---|---|---|
api_url | Yes | Your store URL (e.g., https://yoursite.com) |
product_id | Yes | DDLS product ID |
timeout | No | HTTP request timeout in seconds (default: 30) |
verify_ssl | No | Verify SSL certificates (default: true) |
Downloading Files #
The download() method downloads a file to a local path and optionally verifies the SHA-256 hash:
$success = $client->download(
$result['download_url'],
'/tmp/update.zip',
$result['file_hash'] // optional: verifies integrity
);
if (!$success) {
$error = $client->get_last_error();
// handle error
}
Error Handling #
All methods return false on error. Use get_last_error() to retrieve the error:
$result = $client->check_update('XXXX-XXXX-XXXX-XXXX', '1.0.0');
if ($result === false) {
$error = $client->get_last_error();
// $error['code'] and $error['message']
}
