PHP code example of itpalert / web2sms-notification-channel

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

    

itpalert / web2sms-notification-channel example snippets


// .env
...
WEB2SMS_KEY=8c78axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
WEB2SMS_SECRET=e9a689cfxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
WEB2SMS_SMS_FROM=ALERT
WEB2SMS_ACCOUNT_TYPE=prepaid
...

    'web2sms' => [
        'key' => env('WEB2SMS_KEY'),
        'secret' => env('WEB2SMS_SECRET'),
        'sms_from' => env('WEB2SMS_SMS_FROM', ''),
        'account_type' => env('WEB2SMS_ACCOUNT_TYPE', 'prepaid'),
    ],

public function routeNotificationForWeb2sms(Notification $notification)
{
    return $this->phone_number;
}
 php
use ITPalert\Web2smsChannel\Messages\Web2smsMessage;
use Illuminate\Notifications\Notification;

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

    public function toWeb2sms($notifiable)
    {
        return new Web2smsMessage('Content');
    }
}