This package makes it easy to send sms notification using Telenor Myanmar Business SMS service with laravel. You can access Telenor Myanmar Developer Portal from here.
Via Composer
$ composer require solvecase/telenorbulksms
Open up .env file and add the following:
TELENOR_API_BASE_URL=https://prod-apigw.mytelenor.com.mm/
TELENOR_SMS_CALLBACK_URL=oauth2/telenorsms/callback
TELENOR_SMS_CLIENT_ID=
TELENOR_SMS_CLIENT_SECRET=
TELENOR_SMS_SENDER=
TELENOR_SMS_USERNAME=
TELENOR_SMS_PASSWORD=
Open up config/app.php and find the providers key.
'providers' => [
...
SolveCase\TelenorBulkSms\TelenorBulkSmsServiceProvider::class,
]
Laravel Task Scheduling is used to request bearer access token every hour and save it in cache. So, add the following Cron entry to your server interval every minute.
* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1
Using Laravel Notification
<?php
namespace App;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable
{
use Notifiable;
/**
* Route notifications for the telenor sms channel.
*
* @param \Illuminate\Notifications\Notification $notification
* @return string
*/
public function routeNotificationForTelenorSms($notification)
{
return $this->mobile_no; // 959xxxxxxxx
}
}
<?php
namespace App\Notifications;
use Illuminate\Notifications\Notification;
use SolveCase\TelenorBulkSms\TelenorMessage;
use SolveCase\TelenorBulkSms\TelenorSmsChannel;
class InvoicePaid extends Notification
{
/**
* Get the notification channels.
*
* @param mixed $notifiable
* @return array|string
*/
public function via($notifiable)
{
return [TelenorSmsChannel::class];
}
/**
* Get the sms representation of the notification.
*
* @param mixed $notifiable
* @return TelenorMessage
*/
public function toTelenorSms($notifiable)
{
return TelenorMessage::create()
->content($notifiable->inovice->id . ' has been paid!');
}
}
$user->notify(new InvoicePaid($invoice));
Notification::send($users, new InvoicePaid($invoice));
<?php
namespace App\Http\Controllers;
use SolveCase\TelenorBulkSms\TelenorSmsClient;
use SolveCase\TelenorBulkSms\TelenorMessage;
class SmsController extends Controller{
public function sendsms(){
try{
$message = TelenorMessage::create('Hello, Good Morning!')
->to(959xxxxxxxx)->toArray();
$client = new TelenorSmsClient();
$response = $client->send($message)->getBody();
}catch(\Exception $ex){
return back()->withErrors('Something went wrong.');
}
}
}
Please see the changelog for more information on what has changed recently.
Please see contributing.md for details and a todolist.
If you discover any security related issues, please email author email instead of using the issue tracker.
license. Please see the license file for more information.