PHP code example of allanvb / laravel-semysms

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

    

allanvb / laravel-semysms example snippets


'providers' => [
    // Other service providers...

    Allanvb\LaravelSemysms\SemySmsServiceProvider::class,
],

'aliases' => [
    ...
    'SemySMS' => Allanvb\LaravelSemysms\Facades\SemySMS::class,
],

use Allanvb\Semysms\Facades\SemySMS;

SemySMS::sendOne([
    'to' => '+1234567890',
    'text' => 'My first message.'
]);

app('semy-sms')->sendOne([
    'to' => '+1234567890',
    'text' => 'My first message.'
]);

SemySMS::sendOne([
    'to' => '+1234567890',
    'text' => 'Test message'
]);

SemySMS::sendMultiple([
    'to' => ['+1234567890','+1567890234','+1902345678'],
    'text' => 'Test message'
]);

$messages = SemySMS::multiple();

$messages->addRecipient([
    'to' => '+1234567890',
    'text' => 'Test message',
]);

$messages->addRecipient([
    'to' => '+1567890234',
    'text' => 'Test message 2',
]);

$messages->send();

SemySMS::ussd([
    'to' => '*123#'
]);

SemySMS::getOutbox();

SemySMS::getOutbox([
    'interval' => Interval::days(3)
]);

SemySMS::getInbox();

SemySMS::deleteOutbox();

SemySMS::deleteInbox();

SemySMS::getDevices();

SemySMS::cancelSMS();

use Illuminate\Notifications\Notification;
use Allanvb\LaravelSemysms\Channels\SemySmsChannel;
use Allanvb\LaravelSemysms\Channels\SemySmsMessage;

class MyNotification extends Notification
{
    public function via($notifiable)
    {
        return [SemySmsChannel::class];
    }

    public function toSemySms($notifiable)
    {
        return (new SemySmsMessage)
            ->text('My first notification message.');
    }

}


// User model

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

public function toSemySms($notifiable)
{
    return (new SemySmsMessage)
            ->to('+1234567890')
            ->text('My second notification message.');
}

$startDate = Carbon::yesterday()->subDays(1);
$endDate = Carbon::yesterday();

Interval::create($startDate, $endDate);