1. Go to this page and download the library: Download zgabievi/laravel-sender 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/ */
use Zorb\Sender\Enums\MessageStatus;
use Zorb\Sender\Enums\MessageType;
use Zorb\Sender\Facades\Sender;
class SenderController extends Controller
{
//
public function __invoke()
{
// recipient who should get sms
$mobile_number = '5XXXXXXXX';
// content of the message
$message = 'Welcome, you are getting this message from integration';
// type of the message
$type = MessageType::Advertising; // MessageType::Information
$result = Sender::send($mobile_number, $message, $type);
if (isset($result->data[0])) {
// $result->data[0]->messageId
// $result->data[0]->statusId
if ((int)$result->data[0]->statusId === MessageStatus::Delivered) {
// message has been sent
}
} else {
// message was not sent
}
}
}
use Zorb\Sender\Enums\MessageStatus;
use Zorb\Sender\Facades\Sender;
class SenderController extends Controller
{
//
public function __invoke()
{
// message id provided by send method
$message_id = 0000;
$result = Sender::check($message_id);
if (isset($result->data[0])) {
// $result->data[0]->messageId
// $result->data[0]->statusId
// $result->data[0]->timestamp
if ((int)$result->data[0]->statusId === MessageStatus::Delivered) {
// message has been delivered
}
} else {
// message status check failed
}
}
}
use Illuminate\Notifications\Notification;
use Zorb\Sender\Notifications\SMSMessage;
use Zorb\Sender\Channels\SenderChannel;
use Illuminate\Support\Facades\Log;
class WelcomeNotification extends Notification
{
//
public function via($notifiable)
{
return [SenderChannel::class];
}
//
public function toSender($notifiable): SMSMessage
{
return (new SMSMessage())
->content('Your message goes here.')
->recipient($notifiable->phone)
->callback(function ($response) { // optional
// use response here
});
}
}