Integration Examples #
Practical integration patterns for common scenarios.
Example 1: WordPress Plugin with License Management and Auto-Updates #
// In your plugin's main file
define('MY_PLUGIN_VERSION', '1.0.0');
define('MY_PLUGIN_PRODUCT_ID', 42);
require_once plugin_dir_path(__FILE__) . 'updater/class-dmsi-update-client.php';
require_once plugin_dir_path(__FILE__) . 'updater/class-dmsi-wp-plugin-updater.php';
require_once plugin_dir_path(__FILE__) . 'updater/class-dmsi-wp-license.php';
function my_plugin_init_updater() {
$client = new DMSI_Update_Client([
'api_url' => 'https://yoursite.com',
'product_id' => MY_PLUGIN_PRODUCT_ID,
]);
// License management UI
$license = new DMSI_WP_License([
'client' => $client,
'slug' => 'my-plugin',
'name' => 'My Plugin Pro',
]);
$license->init();
// Auto-update integration
$updater = new DMSI_WP_Plugin_Updater([
'client' => $client,
'plugin_file' => plugin_basename(__FILE__),
'plugin_slug' => 'my-plugin/my-plugin.php',
'version' => MY_PLUGIN_VERSION,
'license_key' => $license->get_license_key(),
]);
$updater->init();
}
add_action('init', 'my_plugin_init_updater');
// Add license settings to your plugin's admin page
function my_plugin_settings_page() {
global $license;
echo '<h2>License</h2>';
$license->render_settings_section();
}
Example 2: Generic PHP App with Manual Update Check #
$client = new DMSI_Update_Client([
'api_url' => 'https://yoursite.com',
'product_id' => 42,
]);
$update = $client->check_update(
$_SESSION['license_key'],
APP_VERSION,
['channel' => $_SESSION['update_channel'] ?? 'stable']
);
if ($update && $update['update_available']) {
// Show update notification in UI
$update_url = $update['download_url'];
$update_hash = $update['file_hash'];
$update_notes = $update['changelog'];
}
Example 3: Python Desktop App Check on Startup #
import threading
from dmsi_update_client import DmsiUpdateClient
def check_for_updates_in_background(app_window):
client = DmsiUpdateClient(
api_url='https://yoursite.com',
product_id=42
)
result = client.check_update(
license_key=load_license_from_config(),
current_version=APP_VERSION,
channel='stable'
)
if result and result.get('update_available'):
# Notify UI thread
app_window.show_update_banner(result['version'], result['is_critical'])
# Start update check in background thread on app startup
threading.Thread(
target=check_for_updates_in_background,
args=(main_window,),
daemon=True
).start()
Example 4: Checking Server Status Before Startup #
$client = new DMSI_Update_Client([
'api_url' => 'https://yoursite.com',
'product_id' => 42,
]);
$status = $client->get_status();
if (!$status || $status['status'] !== 'ok') {
// Update server unreachable - use cached update info
// Do not block app startup on this
}
