PHP code example of extenbox / notify

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

    

extenbox / notify example snippets




xtenbox\Notify\Notify;

Notify::configure([
    'default' => 'smsir',
    'fallback' => null,
    'auto_send' => false,
    'ssl_verify' => true,
    'log' => ['enabled' => false],
    'drivers' => [
        'smsir' => [
            'api_key' => 'your-api-key',
            'sender' => '3000xxxx',
            'base_url' => 'https://api.sms.ir/v1',
            'ssl_verify' => true,
        ],
    ],
]);

$response = Notify::sms('09123456789', 'سلام')->send();

if ($response->isSuccessful()) {
    echo $response->message;
}



namespace App\Services;

use Extenbox\Notify\NotifyManager;

class SmsService
{
    public function notify(): NotifyManager
    {
        return new NotifyManager([
            'default' => 'smsir',
            'auto_send' => false,
            'ssl_verify' => true,
            'log' => ['enabled' => false],
            'drivers' => [
                'smsir' => [
                    'api_key' => getenv('SMSIR_API_KEY'),
                    'sender' => getenv('SMSIR_SENDER'),
                    'base_url' => 'https://api.sms.ir/v1',
                    'ssl_verify' => true,
                ],
            ],
        ]);
    }
}

$response = service('sms')->notify()
    ->sms('09123456789', 'کد تایید: 1234')
    ->send();

use Extenbox\Notify\Facades\Notify;

Notify::sms('09123456789', 'سلام! خوش آمدید.')->send();

$response = Notify::sms('09123456789', 'پیام')->send();

use Extenbox\Notify\Notify;

Notify::flash('09123456789', 'verify-template', [
    'code' => '12345',
])
    ->via('smsir', '3000xxxx')
    ->send();

use Extenbox\Notify\Notify;

Notify::configureDriver('smsir', [
    'api_key' => 'new-key',
    'sender' => '3000xxxx',
    'ssl_verify' => true,
]);

Notify::setDefault('smsir');
Notify::setFallback('ghasedak');

$smsir = Notify::driver('smsir');
$credit = $smsir->getCredit();
$sent = $smsir->getSentReport(['page' => 1, 'pageSize' => 10]);

$ippanel = Notify::driver('ippanel');
$balance = $ippanel->getCredit();
$message = $ippanel->getMessage(123456);
$inbox = $ippanel->fetchInbox(1, 10);

$ghasedak = Notify::driver('ghasedak');
$account = $ghasedak->accountInfo();
$status = $ghasedak->status(['message-id-1', 'message-id-2']);

$mediana = Notify::driver('mediana');
$balance = $mediana->getBalance();
$lines = $mediana->getLines();

$meliPayamak = Notify::driver('melipayamak');
$credit = $meliPayamak->getCredit();
$messages = $meliPayamak->getMessages(1, 0, 10);

$response = Notify::driver('smsir')->rawGet('report/sent', ['page' => 1]);
$response = Notify::driver('ghasedak')->rawPostForm('sms/status', ['id' => '123', 'type' => 1]);
$response = Notify::driver('ippanel')->rawPost('api/report/messages', ['page' => 1]);
bash
php artisan notify:install
php artisan vendor:publish --tag=Notify-config
php artisan vendor:publish --tag=Notify-migrations
php artisan migrate