PHP code example of thepublicgood / smsportal

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

    

thepublicgood / smsportal example snippets


return [

    //...
    
    'smsportal' => [
        'id' => env('SMSPORTAL_ID'),
        'secret' => env('SMSPORTAL_SECRET'),
    ],

];

SMSPortal::to('27823456789')->message('Hello, World!')->send();

SMSPortal::to(['27823456789', '278209876543'])->message('Hello, all of you!')->send();

use TPG\SMSPortal\Contracts\SMSPortalClient;
use TPG\SMSPortal\Message;

public function sms(SMSPortalClient $client)
{
    $message1 = new Message('27823456789', 'Message number 1');
    $message2 = new Message('27829876543', 'Message number 2');
    
    $response = $client->sendBulk([$message1, $message2]);
}

$response = $client->send($message);

use TPG\SMSPortal\Contracts\SMSPortalClient;
use TPG\SMSPortal\Message;

public function sms(SMSPortalClient $client)
{
    $response = $client->sendGroup('Hello, all of you groups!', ['group1', 'group2']);
}

use TPG\SMSPortal\SMSPortalChannel;

public function via($notifiable): array
{
    return [
        'smsportal',
    ]
}

public function toSMSPortal($notifiable): string
{
    'Hello, '.$notifiable->name;
}

public function routeNotificationForSmsPortal(Notification $notification): string
{
    return $this->mobile;
}

use TPG\SMSPortal\Contracts\SMSPortalClient;
use TPG\SMSPortal\Message;

public function sms(SMSPortalClient $client)
{
    $options = new SendOptions(
        allowContentTrimming: true,
        shortenUrls: true,
    );

    $response = $client->send($message, $options);
}
shell
php ./artisan vendor:publish --provider="TPG\\SMSPortal\\SMSPortalServiceProvider"