A PHP library for sending messages.
$ composer require alaninchika/messenger
Or add to composer.json
:
"require": {
"alaninchika/messenger": "^1.0.0"
}
and then run composer update.
Alternatively you can clone or download the library files.
use Messenger\SMSMessenger;
$smsMessenger = new SMSMessenger();
// Your Account SID and Auth Token from twilio.com/console
$account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$auth_token = 'your_auth_token';
$twilio_number = "+15017122661";
$twilio = new TwilioSMS($account_sid, $auth_token, $twilio_number);
$smsMessenger->registerSMSProvider('twilio', $twilio);
use Messenger\SMSMessenger;
$smsMessenger = new SMSMessenger();
$sns_client = new SnsClient([
'region' => 'eu-west-1',
'version' => 'latest',
'credentials' => [
'key' => 'AWS_ACCESS_KEY_ID',
'secret' => 'AWS_SECRET_ACCESS_KEY',
]
]);
$sns = new SnsSMS($sns_client, 'SNS_TOPIC');
$smsMessenger->registerSMSProvider('sns', $sns);
// Sending sms message with any registered provider
$result = $smsMessenger->sendMessage('15017122664', 'test message');
// Sending sms message with a specific registered provider
$result = $smsMessenger->sendMessageWith('sns', '15017122662', 'test message');
// Success result
['provider' => 'sns', 'result' => ['message_id' => 'e234-11e8', 'sent' => true]]
// Failed result
['provider' => 'sns', 'result' => ['error' => 'error message', 'sent' => false]]
- Guide: CONTRIBUTING.md
- Issue Tracker: github.com/alaninchika/messenger
- Source Code: github.com/alaninchika/messenger
You can find more about contributing in CONTRIBUTING.md.