PHP code example of oscar-team / spryngsms

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

    

oscar-team / spryngsms example snippets


return [
    /*
    |----------------------------------------------------------------------
    | Authentication token
    |----------------------------------------------------------------------
    |
    | Here we need to define the token for api authentication
    |
    */
    'token' => env('SPRYNG_SMS_API_TOKEN'),

    /*
    |----------------------------------------------------------------------
    | From / Originator
    |----------------------------------------------------------------------
    |
    | The sender of the message. Can be alphanumeric string (max. 11 characters)
    | or phonenumber (max. 14 digits in E.164 format like 31612345678)
    |
    */
    'originator' => env('SPRYNG_SMS_FROM_NAME', 'Oscar'),

    /*
    |----------------------------------------------------------------------
    | Route
    |----------------------------------------------------------------------
    |
    | Your given route to send the message on. Can be a valid route
    | ID supplied by Spryng or the default business route.
    |
    */
    'route' => env('SPRYNG_SMS_ROUTE', 'business'),

    /*
    |----------------------------------------------------------------------
    | Route
    |----------------------------------------------------------------------
    |
    | Character encoding of the body. Value can be: plain, unicode or auto
    |
    */
    'encoding' => env('SPRYNG_SMS_ENCODING', 'auto'),

    /*
    |----------------------------------------------------------------------
    | Reference
    |----------------------------------------------------------------------
    |
    | A client reference.
    |
    */
    'reference' => env('SPRYNG_SMS_REFERENCE')
];


use Oscar\Spryngsms\SpryngsmsChannel;
use Oscar\Spryngsms\SpryngsmsMessage;

class BookingNotification extends Notification
{
  public function via(object $notifiable): array
  {
      return [
        SpryngsmsMessage::class
      ];
  }

  public function toSpryngsms(mixed $notifiable): SpryngsmsMessage|string
  {
      return new SpryngsmsMessage($message, $recipients, $originator, $encoding, $route, $reference);
  }
}

public function routeNotificationForSpryngsms(): string
{
    return $this->phone_number;
}
unit tests
bash
php artisan vendor:publish --tag=spryngsms-config
spryngsms.php