PHP code example of mustafaculban / commonroom-php-sdk

1. Go to this page and download the library: Download mustafaculban/commonroom-php-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/ */

    

mustafaculban / commonroom-php-sdk example snippets


use CommonRoom\CommonRoom;
// Initialize the SDK
$commonRoom = new CommonRoom('your-api-key');
// Use services
try {
// Get contacts
$contacts = $commonRoom->contacts()->getContacts();
// Get activity types
$activityTypes = $commonRoom->activities()->getActivityTypes();
// Add a tag
$tag = $commonRoom->tags()->createTag([
'name' => 'My Tag',
'description' => 'Tag description'
]);
} catch (\Exception $e) {
echo "Error: " . $e->getMessage();
}

// Initialize with API key and configuration
$commonRoom = new CommonRoom('your-api-key', [
    'timeout' => 45, // Request timeout in seconds
    'connect_timeout' => 15, // Connection timeout in seconds
    'base_url' => 'https://api.commonroom.io/community/v1' // Optional custom base URL
]);
// Make requests through services
$contacts = $commonRoom->contacts()->getContacts();
bash
composer