PHP code example of connectmedia / sms

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

    

connectmedia / sms example snippets



ConnectMedia\Sms\Client;
use ConnectMedia\Sms\ConnectMediaException;

$client = new Client(getenv('CM_API_KEY'));

try {
    $client->send('0712345678', 'Your order has shipped.', ['sender' => 'YourBrand']);
    $client->send(['0712345678', '0733000111'], 'Fees are due on Friday.', [
        'sender'     => 'YourSchool',
        'scheduleAt' => new DateTimeImmutable('2026-12-01 09:00:00'),
    ]);
    print_r($client->balance());
    print_r($client->history(10));
    print_r($client->inbox(10));
} catch (ConnectMediaException $e) {
    echo $e->apiCode, ' ', $e->apiMessage;
}
bash
php tests/run.php