PHP code example of atymic / sms-broadcast

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

    

atymic / sms-broadcast example snippets


$client = \Atymic\SmsBroadcast\Factory\ClientFactory::create(
    'username',
    'password',
    '0412345678' // Default sender, optional
);

try {
    $response = $client->send('0487654321', 'This is an sms message');
} catch (\Atymic\SmsBroadcast\Exception\SmsBroadcastException $e) {
    echo 'Failed to send with error: ' . $e->getMessage();
}

echo 'SMS sent, ref: ' . $response->getSmsRef();

$to = ['0487654321', '0487654322', '0487654323']
$responses = $client->sendMultiple($to, 'This is an sms message');

foreach ($responses as $response) {
    echo $response->hasError()
        ? 'Failed to send SMS: ' . $response->getError()
        : 'SMS sent, ref: ' . $response->getSmsRef();
}

echo $client->getBalance(); // int(1222)