2017 © Pedro Peláez
 

library sms

Using different SMS gateway to send SMS for different phone number format

image

zblue89/sms

Using different SMS gateway to send SMS for different phone number format

  • Friday, September 30, 2016
  • by zblue89
  • Repository
  • 0 Watchers
  • 0 Stars
  • 98 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

PHP SMS

The purpose of this package is to allow the user to use different SMS gateway to send the SMS to different phone number format., (*1)

For example, you may use Twilio to send SMS to US phone number, and Plivo to send SMS to Malaysian phone number., (*2)

Currently the package just support 4 SMS gateways, which are log (show the message in log file), Twilio, Plivo, and Generic (perform HTTP POST to the configured URL). If you are to use Twilio and/or Plivo, you have to include twilio\twilio-sdk and/or plivo/plivo in your project., (*3)

Installation

  1. Add zblue89\php-sms to your composer:, (*4)

    composer require zblue89\php-sms
  2. Add \Zblue89\Sms\SmsServiceProvider::class into providers section in config\app.php file., (*5)

    'providers' => [
        ...
        Zblue89\Sms\SmsServiceProvider::class
        ...
    ]
  3. Add 'SMS' => Zblue89\Sms\Facades\SMS::class into aliases section in config\app.php file., (*6)

    'aliases' => [
        ...
        'SMS' => Zblue89\Sms\Facades\SMS::class,
        ...
    ]
  4. Copy sms.php configuration file from vendor\zblue89\php-sms\src\config folder to config folder., (*7)

Configuration

You may provide multiple sets of SMS configuration in config/sms.php., (*8)

format - the phone number regular expression format. E.g. /^60\d+$/ for Malaysian phone number., (*9)

gateway - the SMS gateway to be used for the provided format. Currently it only supports log, twilio, plivo, and generic., (*10)

The following configuration are required for Plivo SMS gateway:, (*11)

plivo_auth_id - Plivo Authentication ID, (*12)

plivo_auth_token - Plivo Authentication Token, (*13)

plivo_source - Source for Plivo, (*14)

The following configuration are required for Twilio SMS gateway:, (*15)

twilio_sid - Twilio SID, (*16)

twilio_auth_token - Twilio Authentication Token, (*17)

twilio_from_number - Twilio From Number, (*18)

The following configuration are required for Generic SMS gateway:, (*19)

generic_url - POST URL, (*20)

generic_parameters - Additional parameters to be included during the HTTP POST, (*21)

generic_phone_number_parameter_name - Parameter name for Phone Number during the HTTP POST, (*22)

generic_message_parameter_name - Parameter name for Message during the HTTP POST, (*23)

generic_good_response - Expected response body from HTTP POST. An exception will be thrown if the response body does not match with this value. This value is nullable. If it is null, the process is considered as success all the time., (*24)

Example of configuration:

[
    'format' => '/^60\d+$/,
    'gateway' => 'plivo',
    'plivo_auth_id' => 'XXXXXXX'
    'plivo_auth_token' => 'XXXXXX',
    'plivo_source' => 'tapway'
], 
[
    'format' => '/^65\d+$/,
    'gateway' => 'twilio',
    'twilio_sid' => 'XXXXXXX'
    'twilio_auth_token' => 'XXXXXX',
    'twilio_from_number' => '0123456789'
]

Usage

Using SMS provider service is very simple:, (*25)

SMS::send('<phone number>', '<message>');

The Versions

30/09 2016

dev-master

9999999-dev

Using different SMS gateway to send SMS for different phone number format

  Sources   Download

The Requires

 

by Avatar zblue89

sms laravel5

30/09 2016

2.0.0

2.0.0.0

Using different SMS gateway to send SMS for different phone number format

  Sources   Download

The Requires

 

by Avatar zblue89

sms laravel5

18/12 2014

1.0.0

1.0.0.0

  Sources   Download

The Requires

 

by Avatar zblue89