GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - msonowal/laravel-notification-channel-textlocal: Notification channel for textlocal sms service

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

68 Commits
68 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
config
config
 
 
src
src
 
 
tests
tests
 
 
CHANGELOG.md
CHANGELOG.md
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
LICENSE.md
LICENSE.md
 
 
README.md
README.md
 
 
composer.json
composer.json
 
 
phpunit.xml.dist
phpunit.xml.dist
 
 
scrutinizer.yml
scrutinizer.yml
 
 
styleci.yml
styleci.yml
 
 
travis.yml
travis.yml
 
 

Repository files navigation

This package allows to send SMS using Textlocal API using laravel notifications channel textlocal sms

Supports Laravel 5.5 upto 10.x

Latest Stable Version License Total Downloads

This package makes it easy to send notifications using textlocal with Laravel 5.3.+

To use version ^2.3.0 onwards will require PHP 8.0

for other PHP version use upto ^2.2.0

Contents

  • Installation
    • Setting up the textlocal service
  • Usage
    • Available Message methods
  • Changelog
  • Testing
  • Security
  • Contributing
  • Credits
  • License

Installation

Create an account in textlocal then create an API key or hash(password).

composer require msonowal/laravel-notification-channel-textlocal

Setting up the textlocal service

default config textlocal.php update where desired

Important Either specify a Key OR a Hash - don't enter both!

return [
	'username'  => env('TEXTLOCAL_USERNAME'),
	'password'  => env('TEXTLOCAL_PASSWORD'),
	'hash'      => env('TEXTLOCAL_HASH'),  //optional if api_key is set
	'api_key'   => env('TEXTLOCAL_API_KEY'), //optional if hash is set
	'sender'    => env('TEXTLOCAL_SENDER'),
	'request_urls' => [
		'IN' => 'https://api.textlocal.in/',
		'UK' => 'https://api.txtlocal.com/'
	],
	'country'   => env('TEXTLOCAL_COUNTRY', 'IN'),
    'extra' => [
        // extra config define keys as desired for use within the textlocal client config
        // if you want to use the custom client config for each notification or notifiable 
        // INotificationUsesTextlocalClientConfig
    ]public function getSenderId($notifiable)
### Configuring .env
TEXTLOCAL_USERNAME=Your email id or api key
TEXTLOCAL_HASH=get it from url '/docs/' under your API KEYS section
TEXTLOCAL_API_KEY get it from url '/docs/' under your API KEYS section
TEXTLOCAL_SENDER=Name of the Sender that will be displayed to the recipient (max 6 Characters).
TEXTLOCAL_COUNTRY=Your Two letter(ISO-3166-alpha-2) Country Code. It should be the Country of the TEXTLOCAL account. defaults to IN

### Publish Config
php artisan vendor:publish --tag=textlocal

Currently, only textlocal of two country is supported IN(India) and UK(United Kingdom). 

## Usage

Implement this method `routeNotificationForTextlocal()` in your notifiable class/model which will return array of mobile numbers. Please make sure the mobile number contains the dial code as well (e.g +91 for India). And lastly implement `toSms()` method in the notification class which will return the (string) sms or template that is defined in textlocal account that needs to be send.


## Usage

You can use the channel in your `via()` method inside the notification:

```php
use Illuminate\Notifications\Notification;
use NotificationChannels\Textlocal\TextlocalChannel;

class TestOTPNotification extends Notification
{
    public function via($notifiable)
    {
        return [TextlocalChannel::class];
    }

    public function toSms($notifiable)
    {
        return 'Use 1234 as OTP for resetting your password.';
    }
}

In your notifiable model, make sure to include a routeNotificationForTextlocal() method, which returns a phone number or multiple numbers in array or an array of phone numbers.

public function routeNotificationForTextlocal(): array
{
    return [$this->mobile_no];
}

Annoynmous Notifable when say mobile no is not added to a notifiable model you can directly send to mobile no by using that

Notification::route('Textlocal', $mobileNo')->notify(new VerifyMobileNotification($otp));

Available Message methods

And if you want to have a specific sender based on Notification, e.g. like you are sending promotional notification using one and another for transaction then you can just define this method in your notification class which will return your sender id for that notification only

public function getSenderId($notifiable)
{
     return 'YOUR_SENDER_ID';
}

Unicode support If you want to send the notification content to have unicode support. Define this method in your notification which will return boolean based on which the sms will set the unicode mode in textlocal API

public function getUnicodeMode()
{
     return true;
}

A list of all available options

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Found any bugs or improvement open an issue or send me a PR

Contributing

Please see CONTRIBUTING for details.

Credits

  • Manash Jyoti Sonowal
  • Mr Ejang
  • Sinadh
  • All Contributors

License

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

TODO

Need to convert to Guzzle Http as a Client in core Add more countries add tests

About

Notification channel for textlocal sms service

Topics

laravellaravel-notification-channelslaravel-packagesmstextlocal

Resources

Readme
MIT license

Contributing

Contributing
Activity

Stars

5 stars

Watchers

1 watching

Forks

8 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.