PHP Classes

How to Use a PHP Send SMS API to Send Messages to Africans Using the Package Laravel Notification Channel Termii: Send messages to other people with the Termii API

Recommend this page to a friend!
  Info   View files Documentation   View files View files (16)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2024-04-27 (10 hours ago) RSS 2.0 feedNot yet rated by the usersTotal: Not yet counted Not yet ranked
Version License PHP version Categories
laravel-notification 1.0The PHP License5PHP 5, Wireless and Mobile, Web services
Description 

Author

This package can send messages to other people with the Termii API.

It can send HTTP requests to the Termii API Web server to send messages to other people.

The messages can be sent by SMS to people with a given phone number or to a channel that may route messages via WhatsApp or avoid disturbing the recipient during specific hours when they do not want to receive them.

Picture of Edward Paul
  Performance   Level  
Name: Edward Paul <contact>
Classes: 18 packages by
Country: Nigeria Nigeria
Innovation award
Innovation award
Nominee: 10x

Winner: 1x

Documentation

Termii notifications channel for Laravel

This package brings you the joy of sending Termii notifications with Laravel, with the same effortlessness as a Sunday morning coffee. Take a sip and let's get started.

Contents

Installation

You can install the package faster than you can say "composer" via composer:

composer require infinitypaul/laravel-notification-channel-termii

Service providers... You gotta love them. You either have to install them yourself, or if you're living on the edge with Laravel 5.5 or higher, let the package auto discovery do the work for you:

// config/app.php
'providers' => [
    ...
    Infinitypaul\Termii\TermiiServiceProvider::class,
],

Setting up your Termii account

Time to tell Laravel your deepest secret (aka your Termii API Key). Also, add your favorite channel and an optional Sender ID. Whisper these to your config/services.php:

// config/services.php
'termii' => [
'api_key' => env('TERMII_API_KEY'),
'from' => env('TERMII_FROM'),
'channel' => 'dnd' //because I know you love 'do not disturb' mode ?
]

Usage

The next step is as easy as pie. Simply use the channel in your via() method inside the notification:

use Infinitypaul\Termii\TermiiChannel;
use Infinitypaul\Termii\TermiiMessage;
use Illuminate\Notifications\Notification;

class WelcomeSMS extends Notification
{
    public function via($notifiable)
    {
        return [TermiiChannel::class]; // see? pie!
    }

    public function toTermii($notifiable)
    {
        return (new TermiiMessage())
            ->content("Thanks For Subscribing to infinitypaul.medium.com. We promise to only send interesting stuff, no cat videos... well, maybe just one.");
    }
}

Let's tell your Notification where it's heading(which phone are you sending to). Add the routeNotificationForTermii method to your Notifiable model (e.g., your User Model).

public function routeNotificationForTermii()
{
    return $this->phone; // where `phone` is a field in your users table;
}

or you can also just send it from TermiiMessage class in your toTermii() implementation.

public function toTermii($notifiable)
    {
        return (new TermiiMessage())
            ->content("Thanks For Subscribing to infinitypaul.medium.com. We promise to only send interesting stuff, no cat videos... well, maybe just one.")
            ->to("234100000001");
    }

Available Message methods

TermiiMessage

  • `from('')`: Accepts a string -Represents a sender ID for sms which can be Alphanumeric or Device name for Whatsapp. Alphanumeric sender ID length should be between 3 and 11 characters (Example:CompanyName).
  • `to('')`: Accepts a string - Represents a destination ID for sms in international format (Example: 2338013828492). It is optional, and can be set in the notifable model `routeNotificationForTermii()`.
  • `content('')`: Accepts a string - Text of a message that would be sent to the destination phone number.
  • `channel('')`: Accepts a string This is the route through which the message is sent. It is either `dnd`, `whatsapp`, or `generic`, by default it is dnd.
  • `media('')`: Accepts an array, if your channel is `whatsapp` This is a media object, it is only available for the High Volume WhatsApp. When using the media parameter, ensure you are not using the sms parameter.
  • `media_url('')`: Accepts a string, if your channel is `whatsapp` The url to the file resource,.
  • `media_option('')`: Accepts a string, if your channel is `whatsapp` The caption that should be added to the image,.

Changelog

Curious about our termii journey? Check out CHANGELOG for more information on what has changed recently.

Testing

composer test //(We promise it won't explode.)

Security

Discovered any security issues? Please email us at infinitypaul@live.com. We promise to take it seriously, instead of using the issue tracker..

Credits

License

The MIT License (MIT). Please see License File for more information.


  Files folder image Files  
File Role Description
Files folder image.github (1 directory)
Files folder imagesrc (4 files, 1 directory)
Files folder imagetests (1 file)
Accessible without login Plain text file .editorconfig Data Auxiliary data
Accessible without login Plain text file .styleci.yml Data Auxiliary data
Accessible without login Plain text file CHANGELOG.md Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file CONTRIBUTING.md Data Auxiliary data
Accessible without login Plain text file LICENSE.md Lic. License text
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  .github  
File Role Description
Files folder imageworkflows (1 file)

  Files folder image Files  /  .github  /  workflows  
File Role Description
  Accessible without login Plain text file tests.yml Data Auxiliary data

  Files folder image Files  /  src  
File Role Description
Files folder imageExceptions (2 files)
  Plain text file Termii.php Class Class source
  Plain text file TermiiChannel.php Class Class source
  Plain text file TermiiMessage.php Class Class source
  Plain text file TermiiServiceProvider.php Class Class source

  Files folder image Files  /  src  /  Exceptions  
File Role Description
  Plain text file CouldNotSendNotification.php Class Class source
  Plain text file NotSet.php Class Class source

  Files folder image Files  /  tests  
File Role Description
  Plain text file ExampleTest.php Class Class source

 Version Control Unique User Downloads  
 100%
Total:0
This week:0