PHP code example of lapix / celmedia-sms

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

    

lapix / celmedia-sms example snippets




use Lapix\Celmedia\Sms\Client;
use Lapix\Celmedia\Sms\SmsSender;
use Lapix\Celmedia\Sms\SmsFactory;
use Lapix\Celmedia\Sms\JsonEncoder;
use Lapix\Celmedia\Sms\SmsSanitizer;
use Lapix\Celmedia\Sms\CelmediaSmsException;

$sanitizer = new SmsSanitizer();
$createSms = new SmsFactory($sanitizer);

$sender = new SmsSender(
    new Client(
        new \GuzzleHttp\Client(),
        'username',
        'password',
        'apiKey'
    ),
    new JsonEncoder()
);

try {
    // Send multiple sms.'Test méssage' is sent as 'Test message'
    $sender->send([$createSms->createSms('Test méssage', '3111111111', '123456')]);
    // or a single
    $sender->sendSingle($createSms->createSms('Test message', '3111111111', ''));
} catch (CelmediaSmsException $exception) {
    // Internal server error
}