PHP code example of alif / alif-sms-notification
1. Go to this page and download the library: Download alif/alif-sms-notification 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/ */
alif / alif-sms-notification example snippets
return [
'host' => env('SMS_NOTIFICATION_HOST'),
'method' => 'POST',
'headers' => [
'X-Api-Key' => env('SMS_NOTIFICATION_API_KEY'),
'Content-type' => 'application/json',
'charset' => 'utf-8'
],
'routes' => [
'send_sms' => '/api/v1/Sms'
],
];
$smsSender = new SmsNotificationSender();
//OR
$smsSender = SmsNotificationSender::make();
$smsSender->from('John Doe')
->to('123456789')
->send('Message text');
//or
SmsNotificationSender::make()
->from('John Doe')
->to('123456789')
->send('Message text');
$smsSender = new SmsNotificationSender();
//OR
$smsSender = SmsNotificationSender::make();
$smsSender->from('John Doe')
->to('123456789')
->sendAsinc('Message text');
$smsSender = SmsNotificationSender::make();
$smsSender->from('John Doe')
->to('123456789')
->onFail(function(Exception $e) {
// do something ...
})->onSuccess(function(ResponseInterface $response) {
// do smth ...
})->send('Message text');
$smsSender = SmsNotificationSender::make();
$smsSender->from('John Doe')
->to('123456789')
->headers($headers)
->onFail(function(Exception $e) {
//...
})->onSuccess(function(ResponseInterface $response) {
//...
})->send('Message text');
$smsSender = SmsNotificationSender::make();
$smsSender->from('John Doe')
->to('123456789')
->priority($priority)
->onFail(function(Exception $e) {
//...
})->onSuccess(function(ResponseInterface $response) {
//...
})->send('Message text');
$smsSender->from('John Doe')
->to('123456789')
->expiresIn($expiresIn)
->onFail(function(Exception $e) {
//...
})->onSuccess(function(ResponseInterface $response) {
//...
})->send('Message text');
$smsSender->from('John Doe')
->to('123456789')
->countryCode($countryCode)
->onFail(function(Exception $e) {
//...
})->onSuccess(function(ResponseInterface $response) {
//...
})->send('Message text');