mustafaculban/commonroom-php-sdk

PHP SDK for Common Room API

v1.0.0 2024-11-28 12:38 UTC

This package is auto-updated.

Last update: 2025-06-13 16:48:25 UTC


README

Un-Official PHP SDK for Common Room API integration.

Installation

You can install the package via composer:

composer require mustafaculban/commonroom-php-sdk

Usage

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();
}

Advanced Configuration

You can pass additional configuration options when initializing the SDK:

// 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();

Available Services

  • ApiTokenService
  • ActivitiesService
  • ContactsService
  • SegmentsService
  • TagsService

Testing

To run the tests, you'll need to set up your test environment:

  1. Copy .env.testing.example to .env.testing:
cp .env.testing.example .env.testing
  1. Update .env.testing with your test API key:
COMMONROOM_TEST_API_KEY=your-test-api-key-here
  1. Run the tests:
composer test

Note: For CI/CD, make sure to set the COMMONROOM_TEST_API_KEY secret in your GitHub repository settings.

Documentation

For detailed API documentation, please visit Common Room API Documentation.

Contributing

Please see CONTRIBUTING.md for details.

License

The MIT License (MIT). Please see License File for more information.