PHP code example of androidneha / laravel-msg91

1. Go to this page and download the library: Download androidneha/laravel-msg91 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/ */

    

androidneha / laravel-msg91 example snippets


Laravel\Msg91\ServiceProvider::class

'Msg91' => Laravel\Msg91\Facade::class,



$result = Msg91::sms('919999999999', 'Hello there!');
 
$result = Msg91::sms('919999999999', 'Hello there!', 'TEST12');
 
$result = Msg91::sms(null, [
    ['to' => ['919999999999', '918888888888'], 'message' => 'Hello there!'],
    ['to' => ['917777777777'], 'message' => 'Come here!'],
], 'TEST12');



$result = Msg91::otp('919999999999');
   
$result = Msg91::otp('919999999999', 'TEST12');
   
$result = Msg91::otp('919999999999', 'TEST12', '##OTP## is your OTP, Please dont share it with anyone.');



$result = Msg91::verify('919999999999', 1290); // returns true or false



/**
 * @param  mixed  $notifiable
 * @return array
 */
public function via($notifiable)
{
    return ['msg91'];
}



use Laravel\Msg91\Message\Msg91Message;

public function toMsg91()
{
    return (new Msg91Message)
        ->message(__('This is just a test message.'))
	->sender('MESG91') // [Optional] - Will pick default sender ID from MSG91_DEFAULT_SENDER or config
	->transactional(); // or promotional() [Optional] - Will pick default route from MSG91_DEFAULT_ROUTE or config
}



public function routeNotificationForMsg91($notification)
{
    return $this->phone_number;
}



$notifiable = /* some class */
$notifiable->notify(new App\Notifications\Msg91TestNotification());


use Illuminate\Support\Facades\Notification

Notification::route('msg91', '919876543210')
    ->notify(new App\Notifications\Msg91TestNotification());



use Illuminate\Support\Facades\Validator

$data = ['number' => '9876543210', 'otp' => '1234'];

$validator = Validator::make($data, [
    'number' => ['validator->fails()) {
    // report errors
}
bash
$ php artisan vendor:publish