A PHP client library for the CAMARA API with built-in OAuth2 authentication and configurable settings.
- π OAuth2 Authentication - Automatic token management with configurable credentials
- π± HLR Lookup - Mobile number validation and operator information
- π€ Customer Premium Info - Retrieve detailed customer information
- π οΈ Configurable - Flexible settings injection for multi-environment support
- π― Clean API - Simple, intuitive method calls with automatic authentication
- π¦ PSR-4 Compliant - Modern PHP package structure
Install via Composer:
composer require infiniteloop/camara-client- PHP >= 7.4
- ext-curl (for HTTP requests)
- ext-json (for JSON handling)
<?php
use InfiniteLoop\CamaraClient\CamaraClient;
// Configure your settings
$settings = [
'token_url' => 'https://your-auth-server.com/oauth/token',
'service_url' => 'https://api.camara.example.com',
'client_id' => 'your-client-id',
'client_secret' => 'your-client-secret',
'opco' => 'IE',
'sp_name' => 'YourServiceProvider'
];
// Create client instance
$client = new CamaraClient($settings);
// Perform HLR lookup
$result = $client->HLRLookup('353871234567');
print_r($result);
// Get customer premium information
$customerInfo = $client->getCustomerPremiumInfo('353871234567');
print_r($customerInfo);The CamaraClient constructor requires an associative array with the following keys:
| Key | Type | Description |
|---|---|---|
token_url |
string | OAuth2 token endpoint URL |
service_url |
string | CAMARA API base URL |
client_id |
string | OAuth2 client ID |
client_secret |
string | OAuth2 client secret |
opco |
string | Operating company code (e.g., 'IE', 'UK') |
sp_name |
string | Service provider name |
$settings = [
'token_url' => 'https://auth.example.com/oauth/token',
'service_url' => 'https://api.camara.example.com/v1',
'client_id' => 'abc123xyz',
'client_secret' => 'secret-key-here',
'opco' => 'IE',
'sp_name' => 'Infinite Loop Development'
];Performs a Home Location Register lookup for a mobile number.
$result = $client->HLRLookup(string $msisdn): arrayParameters:
$msisdn(string): Mobile number in international format (e.g., '353871234567')
Returns:
- Array containing operator information, validity status, and lookup metadata
Example:
$result = $client->HLRLookup('353871234567');
/*
[
'msisdn' => '353871234567',
'operator' => 'Vodafone IE',
'valid' => true,
'ported' => false,
'roaming' => false,
'lookup_time' => '2025-01-15 10:30:45',
'timestamp' => '2025-01-15 10:30:45',
'request_id' => 'hlr_abc123xyz'
]
*/Retrieves detailed customer information for a mobile number.
$result = $client->getCustomerPremiumInfo(string $msisdn): arrayParameters:
$msisdn(string): Mobile number in international format
Returns:
- Array containing customer details, credit information, and account status
Example:
$customerInfo = $client->getCustomerPremiumInfo('353871234567');
/*
[
'msisdn' => '353871234567',
'operator' => 'Three Ireland',
'account_type' => 'prepaid',
'credit_balance' => 15.50,
'active' => true,
'last_topup' => '2025-01-10 14:22:33',
'timestamp' => '2025-01-15 10:30:45',
'request_id' => 'cust_xyz789abc'
]
*/Returns information about the CamaraClient package.
$info = $client->getPackageInfo(): arrayReturns:
- Array with package name, vendor, version, description, and configured settings
Returns the current package version.
$version = $client->getVersion(): stringThe package handles OAuth2 authentication automatically. When you call any API method:
- The client checks if authentication is required
- Requests an access token using client credentials flow
- Includes the token in API requests
- Handles token expiration and errors gracefully
You don't need to manage tokens manually - the package handles everything internally.
The package returns structured arrays with error information when operations fail:
$result = $client->HLRLookup('invalid-number');
if (!$result['valid']) {
echo "Lookup failed: " . $result['error'];
}// Load environment-specific settings
$env = getenv('APP_ENV') ?: 'production';
$configFile = __DIR__ . "/config/{$env}.php";
$settings = require $configFile;
$client = new CamaraClient($settings);class MobileValidationService
{
private $camaraClient;
public function __construct(array $camaraSettings)
{
$this->camaraClient = new CamaraClient($camaraSettings);
}
public function validateNumber(string $msisdn): bool
{
$result = $this->camaraClient->HLRLookup($msisdn);
return $result['valid'] ?? false;
}
}Get comprehensive debug information about authentication and configuration:
$debugInfo = $client->getDebugInfo();
print_r($debugInfo);infiniteloop/camara-client/
βββ src/
β βββ Internal/
β β βββ Auth.php # OAuth2 authentication handler
β βββ CamaraClient.php # Main client class (public API)
βββ composer.json
βββ README.md
β οΈ Never commit credentials - Storeclient_idandclient_secretin environment variables- π Use HTTPS - Always use secure URLs for token and service endpoints
- π Rotate secrets - Regularly rotate your OAuth2 credentials
- π Audit logs - Monitor API usage and authentication attempts
composer testThis package follows PSR-4 autoloading and PSR-12 coding standards.
For issues, questions, or contributions, please visit:
- Packagist: https://packagist.org/packages/infiniteloop/camara-client
- GitHub: [Your repository URL]
This package is open-source software licensed under the MIT license.
Developed by Infinite Loop Development Ltd
- Added configurable settings injection
- Implemented OAuth2 authentication
- Added HLR lookup functionality
- Added customer premium info retrieval
- Improved error handling
- Enhanced documentation
- Initial release
- Basic package structure
- Hello World example
Made with β€οΈ by Infinite Loop Development