PHP code example of infiniteloop / camara-client

1. Go to this page and download the library: Download infiniteloop/camara-client 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/ */

    

infiniteloop / camara-client example snippets




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

$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'
];

$result = $client->HLRLookup(string $msisdn): array

$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'
]
*/

$result = $client->getCustomerPremiumInfo(string $msisdn): array

$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'
]
*/

$info = $client->getPackageInfo(): array

$version = $client->getVersion(): string

$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 = 

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

$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