PHP code example of aasanakey / smsonline

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

    

aasanakey / smsonline example snippets


// config/app.php
'providers' => [
    ...
    \Aasanakey\Smsonline\SmsonlineServiceProvider::class,
],


class User extends Model
{
     public function routeNotificationForMnotify()
    {
        return $this->contact;  // returns a contact number eg 0301045697
    }
}

// config/services.php
...
"host" => env('SMSONLINE_HOST','api.smsonlinegh.com'),
...

// config/services.php
...
"api_key" => env('SMSONLINE_API_KEY',null),
...

// config/services.php
...
"sender_id" => env('SMSONLINE_SENDER_ID',null),
...

use Illuminate\Notifications\Notification;
use Aasanakey\Smsonline\SmsonlineSmsMessage;


class SMSNotification extends Notification
{
    public function via($notifiable)
    {
        return ['smsonlinegh'];
    }

    public function toSmsonline($notifiable)
    {
        return (new SmsonlineSmsMessage)
            ->sender('Sender ID')
            ->content('Your account was approved!')
            ->personalisedValues("List of data for personnalised message content"); // call this method if content has message variables placeholders
    }
}

use Aasanakey\Smsonline\Sms;

$sms = new Sms();
$balance = $api->balance(); // returns balance info object
$amount = $balance->ammount // returns balance ammount
$currencyName = $balance->currencyName // returns the balance currency name
$currencyCode = $balance->currencyCode // return the balance ccurrency code
bash
php artisan vendor:publish --tag=smsonline-config
bash
php artisan vendor:publish --provider="Aasanakey\Smsonline\SmsonlineServiceProvider" --tag="smsonline-config"