2017 © Pedro Peláez
 

library cmsms

Cmsms notification channel for Laravel 5

image

laravel-notification-channels/cmsms

Cmsms notification channel for Laravel 5

  • Thursday, June 1, 2017
  • by laravel-notification-channels
  • Repository
  • 4 Watchers
  • 4 Stars
  • 349 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 7 Versions
  • 17 % Grown

The README.md

CMSMS notifications channel for Laravel

Latest Version on Packagist run-tests Total Downloads, (*1)

This package makes it easy to send CMSMS messages with Laravel., (*2)

Contents

Requirements

  • Sign up for a online sms gateway account
  • Find your API key in account settings

Installation

You can install the package via composer:, (*3)

``` bash composer require laravel-notification-channels/cmsms, (*4)


This package will register itself automatically with Laravel 5.5 and up trough Package auto-discovery. ### Manual installation You can install the service provider for Laravel 5.4 and below: ```php // config/app.php 'providers' => [ ... NotificationChannels\Cmsms\CmsmsServiceProvider::class, ],

Setting up your CMSMS account

Add your CMSMS Product Token and default originator (name or number of sender) to your config/services.php:, (*5)

// config/services.php
...
'cmsms' => [
    'product_token' => env('CMSMS_PRODUCT_TOKEN'),
    'originator' => env('CMSMS_ORIGINATOR'),
],
...

Notice: The originator can contain a maximum of 11 alphanumeric characters., (*6)

Usage

Now you can use the channel in your via() method inside the notification:, (*7)

``` php use NotificationChannels\Cmsms\CmsmsMessage; use Illuminate\Notifications\Notification;, (*8)

class VpsServerOrdered extends Notification { public function via($notifiable) { return ['cmsms']; }, (*9)

public function toCmsms($notifiable)
{
    return CmsmsMessage::create("Your {$notifiable->service} was ordered!");
}

}, (*10)



In order to let your Notification know which phone numer you are targeting, add the `routeNotificationForCmsms` method to your Notifiable model. **Important note**: CMCMS requires the recipients phone number to be in international format. For instance: 0031612345678 ```php public function routeNotificationForCmsms() { return '0031612345678'; }

Available message methods

  • body(''): Accepts a string value for the message body.
  • originator(''): Accepts a string value between 1 and 11 characters, used as the message sender name.
  • reference(''): Accepts a string value for your message reference. This information will be returned in a status report so you can match the message and it's status. Restrictions: 1 - 32 alphanumeric characters. Reference will not work for demo accounts.
  • encodingDetectionType(''): Read about encoding detection here: https://developers.cm.com/messaging/docs/sms#auto-detect-encoding
  • multipart($minimum, $maximum): Accepts a 0 to 8 integer range which allows multipart messages. See the documentation from CM for more information.

Available events

  • SMSSentSuccessfullyEvent: This event will be fired after the message was sent. The event will contain the payload we have sent to CM.
  • SMSSendingFailedEvent: This event will be fired if the message was not sent. The event will contain the response body we received from CM.

Changelog

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

Testing

bash $ composer test, (*12)

Security

If you discover any security related issues, please email michel@enflow.nl instead of using the issue tracker., (*13)

Contributing

Please see CONTRIBUTING for details., (*14)

Credits

Special thanks to Peter Steenbergen for the MessageBird template from where this is mostly based on., (*15)

License

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

The Versions