This is a PHP client library to be used with BongaTech's SMS API See Bonga Tech's Website for more
You can install the package via composer:
composer require vmosoti/bongatech-sms
The Config class requires to fetch some variable from the system environment. These variables are the ones used in initialization of the SMS class. In your .env file:
BONGATECH_USER_ID=
BONGATECH_PASSWORD=
BONGATECH_SENDER_ID=
BONGATECH_CALL_BACK_URL=
To initialize:
$sms = new \VMosoti\BongaTech\SMS();
or simply use the magic helper function:
sms() // you have the SMS object
Each of them is an array of arrays. i.e
$recipients = array(
array(
'MSISDN' => '0722123456',
'LinkID' => '',
'SourceID' => 'your source id here'
),
array(
'MSISDN' => '0775345678',
'LinkID' => '',
'SourceID' => 'source id for this here'
)
);
and messages
$messages = array(
array(
'Text' => 'Message 1 goes here'
),
array(
'Text' => 'Message 2 goes here'
)
);
$message = array(
array(
'Text' => 'This message is for a single recipient'
)
);
$recipient = array(
array(
'MSISDN' => '0722123456',
'LinkID' => '',
'SourceID' => 'your source id here'
)
);
$response = $sms->bulk()->toOne()->send($recipient, $message);
or use helper function
$response = sms()->bulk()->toOne()->send($recipient, $message);
The above returns a single Response object
$message = array(
array(
'Text' => 'This message goes to many recipients'
)
);
$recipients = array(
array(
'MSISDN' => '0722123456',
'LinkID' => '',
'SourceID' => 'source id for recipient 1'
),
array(
'MSISDN' => '0713678900',
'LinkID' => '',
'SourceID' => 'source id for recipient 2'
),
);
$responses = $sms->bulk()->toMany()->send($recipients, $message);
$messages = array(
array(
'Text' => 'This is message for recipient 1'
),
array(
'Text' => 'This is message for recipient 2'
)
);
$recipients = array(
array(
'MSISDN' => '0722123456',
'LinkID' => '',
'SourceID' => 'source id for recipient 1'
),
array(
'MSISDN' => '0713678900',
'LinkID' => '',
'SourceID' => 'source id for recipient 2'
),
);
$responses = $sms->bulk()->toMany()->send($recipients, $messages);
The above two examples returns an array of the Response object. Thus:
foreach($responses as $response){
$response->getCode();
------
}
$response = SMS::getBalance();
or just throw in the helper function
get_balance();
$response
is Response object. thus
$response->getBalance()
In your callback,
$response = \VMosoti\BongaTech\DeliveryReport::get();
It returns Response object,
thus:
$response->getReport();
$response->getMessageID();
$response->getCorrelator();
$response->getSourceID();
See all possible reports here
catch \VMosoti\BongaTech\Exceptions\BongaTechException;
Please see CHANGELOG for more information what has changed recently.
Suggestions, pull requests , bug reporting and code improvements are all welcome. Feel free to get in touch.
If you discover any security related issues, please email vincent@vmosoti.com.
The MIT License (MIT). Please see License File for more information.