This is my personal library to make it easier for developers. This is not offical SDK for smspoh. The main goal to create this package is I hate curl , guzzle or etc .... And I made abstraction. Now I could use easily by calling like this. That is it.
send_smspoh(
['+959790646062','+95943160544'],
'Nice to meet you'
);
Via Composer
$ composer require pyaesone17/sms-poh:^1.1
Publish the config file first.
$ php artisan vendor:publish
Configure the token in the sms-poh.php config file.
'token' => env('SMS_POH_TOKEN', 'Your_token_from_the_dashboard'),
For fetching messages.
- Using Facade
$results = SmsPohFacade::fetch(1);
2.Using Container
$sms = app()->make(pyaesone17\SmsPoh\SmsPoh::class);
$results = $sms->fetch(1);
3.Using function
$resutls = fetch_smspoh(1);
For sending messages.
- Using Facade
$results = SmsPohFacade::send(
['+959790646062','+95943160544'],
'Nice to meet you'
);
$results = SmsPohFacade::send(
'+959790646062',
'Nice to meet you'
);
2.Using Container
$sms = app()->make(pyaesone17\SmsPoh\SmsPoh::class);
$results = $sms->send(
['+959790646062','+95943160544'],
'Nice to meet you'
);
3.Using function
$results = send_smspoh(
['+959790646062','+95943160544'],
'Nice to meet you'
);
If you want to send message as testing purpose, you could pass true as a third parameter.
This package also include custom notification channel for interacting with Laravel Notification features. Here is how to use it.
class SendSmsPohNotification extends Notification
{
use Queueable;
public $message;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct($message)
{
$this->message = $message;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return [pyaesone17\SmsPoh\SmsPohChannel::class];
}
/**
* Get the sms representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toMMSms($notifiable)
{
return [
'message' => $this->message,
'to' => '+959790646062',
'test' => 1,
'callback' => function (...$result)
{
// After sms is being sent or failed
// The callback will fire, here you can
// do whatever you want with the result.
// If you don't want, just pass as null
dd($result);
}
];
}
And Notify like this
$user = App\User::first();
$user->notify(new App\Notifications\SendSmsPohNotification("Hello world"));
The MIT License (MIT). Please see License File for more information.