PHP code example of vaibhavpandeyvpz / msg91

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

    

vaibhavpandeyvpz / msg91 example snippets


Msg91\Laravel\ServiceProvider::class

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



// send an SMS to one number
$result = Msg91::sms(
    '919999999999',
    'Hello there!',
    'MSGIND',
    4 /* 1 = Promotional; 4 = Transactional */,
    [
        'DLT_TE_ID' => '<dlt-registered-template-id>',
    ]
);

// send same/different SMS to multiple numbers
$result = Msg91::sms(
    null,
    [
        ['to' => ['919999999999', '918888888888'], 'message' => 'Hello fellas!'],
        ['to' => ['917777777777'], 'message' => 'Hello vpz!'],
    ],
    'MSGIND',
    4 /* 1 = Promotional; 4 = Transactional */,
    [
        'DLT_TE_ID' => '<dlt-registered-template-id>',
    ]
);



$result = Msg91::otp('919999999999', 'MSGIND', [
    'template_id' => '<msg91-approved-otp-template-id>',
]);



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



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



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



use Msg91\Laravel\Notification\Message as Msg91Message;

public function toMsg91()
{
    return (new Msg91Message)
        ->message(__('This is just a test message.'))
        ->sender('MSGIND')
        ->transactional()
        ->options([
            'DLT_TE_ID' => '<dlt-registered-templated-id>',
        ]);
}



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



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


use Illuminate\Support\Facades\Notification;

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



use Illuminate\Support\Facades\Validator;

$data = ['phone' => '919999999999', 'otp' => '1234'];

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