1. Go to this page and download the library: Download generatorlabs/sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
generatorlabs / sdk example snippets
sic initialization
$client = new GeneratorLabs\Client('your_account_sid', 'your_auth_token');
// With custom configuration
$client = new GeneratorLabs\Client(
'your_account_sid',
'your_auth_token',
[
'timeout' => 45, // Request timeout in seconds
'connect_timeout' => 10, // Connection timeout in seconds
'max_retries' => 5, // Maximum retry attempts
'retry_backoff' => 2 // Backoff multiplier (2x: 1s, 2s, 4s, 8s, 16s)
]
);
try {
// List contact groups
$groups = $client->contact->groups->get();
// Create a contact group
$result = $client->contact->groups->create([
'name' => 'Primary Contacts'
]);
// Update a contact group
$client->contact->groups->update('CG4f3e2d1c0b9a8776655443322110fed', [
'name' => 'Updated Group Name'
]);
// Delete a contact group
$client->contact->groups->delete('CG4f3e2d1c0b9a8776655443322110fed');
} catch(GeneratorLabs\Exception $e) {
echo $e->getMessage();
}
try {
// List all certificate errors
$errors = $client->cert->errors->get();
// Get a specific error by ID
$error = $client->cert->errors->get('CE5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a');
print_r($errors);
} catch(GeneratorLabs\Exception $e) {
echo $e->getMessage();
}
try {
// List all certificate monitors
$monitors = $client->cert->monitors->get();
// Get a specific monitor
$monitor = $client->cert->monitors->get('CM62944aeeee2b46d7a28221164f38976a');
// Create a new certificate monitor
$monitor = $client->cert->monitors->create([
'name' => 'Production Web Server',
'hostname' => 'example.com',
'protocol' => 'https',
'profile' => 'CP79b597e61a984a35b5eb7dcdbc3de53c',
'contact_group' => [
'CG4f3e2d1c0b9a8776655443322110fedc',
'CG5a6b7c8d9e0f1234567890abcdef1234'
],
'tags' => ['production', 'web', 'ssl']
]);
// Update a monitor
$monitor = $client->cert->monitors->update('CM62944aeeee2b46d7a28221164f38976a', [
'name' => 'Updated Server Name',
'tags' => ['production', 'web', 'ssl']
]);
// Delete a monitor
$client->cert->monitors->delete('CM62944aeeee2b46d7a28221164f38976a');
// Pause monitoring
$client->cert->monitors->pause('CM62944aeeee2b46d7a28221164f38976a');
// Resume monitoring
$client->cert->monitors->resume('CM62944aeeee2b46d7a28221164f38976a');
} catch(GeneratorLabs\Exception $e) {
echo $e->getMessage();
}
try {
// List all certificate profiles
$profiles = $client->cert->profiles->get();
// Get a specific profile
$profile = $client->cert->profiles->get('CP79b597e61a984a35b5eb7dcdbc3de53c');
// Create a new profile
$profile = $client->cert->profiles->create([
'name' => 'Standard Certificate Profile',
'expiration_thresholds' => [30, 14, 7],
'alert_on_expiration' => true,
'alert_on_name_mismatch' => true,
'alert_on_misconfigurations' => true,
'alert_on_changes' => true
]);
// Update a profile
$profile = $client->cert->profiles->update('CP79b597e61a984a35b5eb7dcdbc3de53c', [
'expiration_thresholds' => [45, 14, 7],
'alert_on_misconfigurations' => true,
'alert_on_changes' => true
]);
// Delete a profile
$client->cert->profiles->delete('CP79b597e61a984a35b5eb7dcdbc3de53c');
} catch(GeneratorLabs\Exception $e) {
echo $e->getMessage();
}
try {
// Get all hosts across all pages (default page_size: 100)
$allHosts = $client->rbl->hosts->getAll();
foreach ($allHosts as $host) {
echo $host['name'] . ' - ' . $host['host'] . "\n";
}
// With a custom page size
$allHosts = $client->rbl->hosts->getAll(['page_size' => 50]);
} catch(GeneratorLabs\Exception $e) {
echo $e->getMessage();
}
use GeneratorLabs\Webhook;
use GeneratorLabs\Exception;
$header = $_SERVER['HTTP_X_WEBHOOK_SIGNATURE'] ?? '';
$body = file_get_contents('php://input');
$secret = getenv('GENERATOR_LABS_WEBHOOK_SECRET');
try {
$payload = Webhook::verify($body, $header, $secret);
// $payload is the decoded event data
echo $payload['event'];
} catch (Exception $e) {
// Signature verification failed
http_response_code(403);
}