devineonline / smsbroadcast
PHP client for the SMS Broadcast API
8.4
2021-06-16 05:55 UTC
Requires
- php: ^7.3
- guzzlehttp/guzzle: ^7.0
Requires (Dev)
- blastcloud/guzzler: ^1.5
- phpunit/phpunit: ^8
This package is auto-updated.
Last update: 2025-02-16 13:26:56 UTC
README
SmsBroadcast PHP API Client
This is a simple API client for SMS Broadcast.
You can view their API documentation here.
Install
composer require DevineOnline/sms-broadcast
Usage
Creating the client
$client = \DevineOnline\SmsBroadcast\Factory\ClientFactory::create( 'username', 'password', '0412345678' // Default sender, optional );
Sending a message to a single recipient
try { $response = $client->send('0487654321', 'This is an sms message'); } catch (\DevineOnline\SmsBroadcast\Exception\SmsBroadcastException $e) { echo 'Failed to send with error: ' . $e->getMessage(); } echo 'SMS sent, ref: ' . $response->getSmsRef();
Sending a message to a multiple recipients
$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(); }
Check SMS credit balance
echo $client->getBalance(); // int(1222)
Tests
By default only unit tests will run. If you want to run the integration tests, copy the phpunit.dist.xml
file to phpunit.xml
and supply your SMS Broadcast credentials & to number in the file.
WARNING - Integration tests will send real SMS messages, so make sure not to run them in CI.
composer test
Todo
- Support for incoming message webhooks