PHP code example of endroid / cm-sms

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

    

endroid / cm-sms example snippets


use Endroid\CmSms\Client;
use Endroid\CmSms\Exception\RequestException;

$client = new Client();

$options = [
    'sender' => 'Endroid',
    'unicode' => 'auto',
    'minimum_number_of_message_parts' => 1,
    'maximum_number_of_message_parts' => 3,
];

$message = new Message();
$message->addTo('0600000000');
$message->setBody('SMS Messaging is the future!');

// Send single message (to one or more recipients)
try {
    $client->sendMessage($message, $options);
} catch (RequestException $exception) {
    // handle exception
}

// Or bulk send multiple messages (to one or more recipients)
try {
    $client->sendMessages([$message, ...], $options);
} catch (RequestException $exception) {
    // handle exception
}