BongaTech SMS
, (*1)
This is a PHP client library to be used with BongaTech's SMS API See Bonga Tech's Website for more, (*2)
Installation
You can install the package via composer:, (*3)
``` bash
composer require vmosoti/bongatech-sms, (*4)
## Usage
### Providing variables
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=, (*5)
### Initializing the SMS class
To initialize:
``` php
$sms = new \VMosoti\BongaTech\SMS();
or simply use the magic helper function:, (*6)
sms() // you have the SMS object
Recipients and Messages
Each of them is an array of arrays.
i.e, (*7)
$recipients = array(
array(
'MSISDN' => '0722123456',
'LinkID' => '',
'SourceID' => 'your source id here'
),
array(
'MSISDN' => '0775345678',
'LinkID' => '',
'SourceID' => 'source id for this here'
)
);
and messages, (*8)
$messages = array(
array(
'Text' => 'Message 1 goes here'
),
array(
'Text' => 'Message 2 goes here'
)
);
Sending to a single Recipient
$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, (*9)
$response = sms()->bulk()->toOne()->send($recipient, $message);
The above returns a single Response object, (*10)
Sending same sms to many recipients
$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);
Sending different sms to each recipient
$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:, (*11)
foreach($responses as $response){
$response->getCode();
------
}
Querying SMS units balance
$response = SMS::getBalance();
or just throw in the helper function, (*12)
get_balance();
$response
is Response object. thus, (*13)
$response->getBalance()
Delivery Reports
In your callback,, (*14)
$response = \VMosoti\BongaTech\DeliveryReport::get();
````
It returns [Response](https://github.com/VMosoti/bongatech-sms/blob/master/src/Response.php) object,
thus:
$response->getReport();
$response->getMessageID();
$response->getCorrelator();
$response->getSourceID();
```
See all possible reports here, (*15)
Exceptions
catch \VMosoti\BongaTech\Exceptions\BongaTechException;
, (*16)
Changelog
Please see CHANGELOG for more information what has changed recently., (*17)
Contributing
Suggestions, pull requests , bug reporting and code improvements are all welcome. Feel free to get in touch., (*18)
Security
If you discover any security related issues, please email vincent@vmosoti.com., (*19)
Credits
License
The MIT License (MIT). Please see License File for more information., (*20)