2017 © Pedro Peláez
 

library laravel-notification-channel-textlocal

This Driver for textlocal sms to send SMS via Textlocal API through laravel notification

image

msonowal/laravel-notification-channel-textlocal

This Driver for textlocal sms to send SMS via Textlocal API through laravel notification

  • Wednesday, April 4, 2018
  • by msonowal
  • Repository
  • 1 Watchers
  • 0 Stars
  • 265 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 35 Forks
  • 0 Open issues
  • 5 Versions
  • 5 % Grown

The README.md

This package allows to send SMS using Textlocal API using laravel notifications channel textlocal sms, (*1)

Supports Laravel 5.5 upto 10.x, (*2)

Latest Stable Version License Total Downloads, (*3)

This package makes it easy to send notifications using textlocal with Laravel 5.3.+, (*4)

To use version ^2.3.0 onwards will require PHP 8.0, (*5)

for other PHP version use upto ^2.2.0, (*6)

Contents

Installation

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

composer require msonowal/laravel-notification-channel-textlocal, (*8)

Setting up the textlocal service

default config textlocal.php update where desired, (*9)

Important Either specify a Key OR a Hash - don't enter both!, (*10)

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., (*11)

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, (*12)

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, (*13)

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, (*14)

public function getUnicodeMode()
{
     return true;
}

A list of all available options, (*15)

Changelog

Please see CHANGELOG for more information what has changed recently., (*16)

Testing

bash $ composer test, (*17)

Security

If you discover any security related issues, please email manash149@gmail.com instead of using the issue tracker., (*18)

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

Contributing

Please see CONTRIBUTING for details., (*19)

Credits

License

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

TODO

Need to convert to Guzzle Http as a Client in core Add more countries add tests, (*21)

The Versions

04/04 2018

dev-master

9999999-dev https://github.com/laravel-notification-channels/textlocal

This Driver for textlocal sms to send SMS via Textlocal API through laravel notification

  Sources   Download

MIT

The Requires

 

The Development Requires

04/04 2018

v1.0.3

1.0.3.0 https://github.com/laravel-notification-channels/textlocal

This Driver for textlocal sms to send SMS via Textlocal API through laravel notification

  Sources   Download

MIT

The Requires

 

The Development Requires

02/12 2017

v1.0.2

1.0.2.0 https://github.com/laravel-notification-channels/textlocal

This Driver for textlocal sms to send SMS via Textlocal API through laravel notification

  Sources   Download

MIT

The Requires

 

The Development Requires

25/11 2017

v1.0.1

1.0.1.0 https://github.com/laravel-notification-channels/textlocal

This Driver for textlocal sms to send SMS via Textlocal API through laravel notification

  Sources   Download

MIT

The Requires

 

The Development Requires

25/11 2017

v1.0.0

1.0.0.0 https://github.com/laravel-notification-channels/textlocal

This Driver for textlocal sms to send SMS via Textlocal API through laravel notification

  Sources   Download

MIT

The Requires

 

The Development Requires