2017 © Pedro Peláez
 

library unified-sms

Unified SMS library package for Laravel 5 and PHP (Non-Laravel) to send text messages through multiple swappable drivers.

image

victorybiz/unified-sms

Unified SMS library package for Laravel 5 and PHP (Non-Laravel) to send text messages through multiple swappable drivers.

  • Saturday, November 18, 2017
  • by victorybiz
  • Repository
  • 1 Watchers
  • 1 Stars
  • 97 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 1 % Grown

The README.md

Unified SMS

GitHub release Software License Build Status Packagist, (*1)

Unified SMS library package for Laravel and PHP (Non-Laravel) to send text messages through multiple swappable drivers., (*2)

Supported Drivers and Services

It currently ships with the following drivers:, (*3)

Installation

Install using composer, from the command line run:, (*4)

$ composer require victorybiz/unified-sms

Laravel Project

Alternatively, you can add "victorybiz/unified-sms": "^1.1" to your composer.json file's require section and then you'll then need to run composer install or composer update to download it and have the autoloader updated., (*5)

If you use Laravel >= 5.5 you can skip this step and go to configuration, (*6)

If you use Laravel < 5.5, you need to register the service provider with the application. Open up config/app.php and locate the providers key., (*7)

'providers' => [

    Victorybiz\UnifiedSMS\UnifiedSMSServiceProvider::class,

]

And add the UnifiedSMS alias to config/app.php:, (*8)

'aliases' => [

    'UnifiedSMS' => Victorybiz\UnifiedSMS\Facades\UnifiedSMSFacade::class,

]

Configuration (Laravel)

You must publish the package's configuration files, (unified-sms.php also published with this) And add the UnifiedSMS alias to config/app.php:, (*9)

php artisan vendor:publish --tag=unified-sms

Open up config/unified-sms.php use the env variables to set your DEFAULT DRIVER and API Credentials., (*10)

Usage in Laravel Project

Please use the UnifiedSMS Facade, (*11)

use UnifiedSMS;

You're good to go, send sms, (*12)

$msg = [
            'from' => 'Your sender ID here', // default_sender_id set in config file will be used if this line is removed or comment out
            'to' => 'The recipent mobile number, international format without the leading plus (+)',
            'text' => 'Your text message here.',
       ];
$response = UnifiedSMS::sendSMS($msg);

Usage in PHP (Non-Laravel) Project

Require the vendor autoload file in your php script., (*13)

require_once 'path/to/vendor/autoload.php';

Create a unified_sms_config.php file anywhere in your project directory. Enter the following block into your unified_sms_config.php and set your DEFAULT DRIVER and API Credentials., (*14)

<?php
$unified_sms_config = [
    /*
    |--------------------------------------------------------------------------
    | Default SMS driver
    |--------------------------------------------------------------------------
    | This option controls the default SMS driver to use.
    |
    | Supported: "null", "routemobile", "nexmo", "moreify", "betasms", "multitexter"
    */
    'default_sms_driver' => 'null',

    /*
    |--------------------------------------------------------------------------
    | Default VOICE SMS driver
    |--------------------------------------------------------------------------
    | This option controls the default Voice SMS driver to use.
    |
    | Supported: "null"
    */
    'default_voice_sms_driver' => 'null',

    /*
    |--------------------------------------------------------------------------
    | Drivers
    |--------------------------------------------------------------------------
    | Here you can define the settings for each driver. 
    */
    'drivers' => [
        'null' => [
            'sms' => [
                'default_sender_id' => 'Null',
                'api_key' => 'null'
            ],
            'voice' => [
                'default_caller_id' => '+1000',
                'api_key' => 'null',
            ],            
        ],
        'routemobile' => [
            'sms' => [
                'default_sender_id' => 'INFO',
                'server' => '',
                'port' => '8080',
                'username' => '',
                'password' => '',
            ],          
        ],
        'nexmo' => [
            'sms' => [
                'default_sender_id' => 'INFO',
                'api_key' => '',
                'api_secret' => '',
                'callback_url' => null, // The webhook endpoint the delivery receipt for this sms is sent to. 
                                    // If set, it overrides the webhook endpoint you set in Dashboard 
            ], 
        ],
        'moreify' => [
            'sms' => [
                'project' => '',
                'password' => '',
            ], 
        ],
        'betasms' => [
            'sms' => [
                'default_sender_id' => 'INFO',
                'username' => '',
                'password' => '',
            ], 
        ],
        'multitexter' => [
            'sms' => [
                'default_sender_id' => 'INFO',
                'email' => '',
                'password' => '',
                'force_dnd' => true,
            ], 
        ],
    ],
];

Require the config file in your php script., (*15)

require_once 'path/to/unified_sms_config.php';
use Victorybiz\UnifiedSMS\UnifiedSMS;

$unifiedSMS = new UnifiedSMS($unified_sms_config); 

Alternatively, (*16)

$unifiedSMS = new \Victorybiz\UnifiedSMS\UnifiedSMS($unified_sms_config);

You're good to go, send sms, (*17)

$msg = [
            'from' => 'Your sender ID here', // default_sender_id set in config file will be used if this line is removed or comment out
            'to' => 'The recipent mobile number, international format without the leading plus (+)',
            'text' => 'Your text message here.',
       ];
$response = $unifiedSMS->sendSMS($msg);

Response from Drivers

On successful, $response will return json data, (*18)

{
    "status":true,
    "statusCode":200,
    "statusDescription":"Success",
    "data": {
        "to":"Recipient phone number",
        "messageId":"The Message ID from the driver service provider",
        "_comment":"May include additional data but depends on the response from the driver service provider"
    },
    "driver":"the default driver used"
}

On failure, $response will return json data, (*19)

{
    "status":false,
    "statusCode":"status error code here",
    "statusDescription":"Status description / message",
    "data":null,
    "driver":"the default driver used"
}

The failure status codes are, (*20)

200             Success
1001            Invalid URL or Missing Params
1002            Invalid credentials
1003            Invalid recipient
1004            Invalid sender
1005            Invalid message
1006            Invalid message type
1007            Invalid delivery
1008            Insufficient credit
1009            Response timeout
1010            Internal error
1011            Account Suspended

Bug Reports and Issue tracking

Kindly make use of the issue tracker for bug reports, feature request, additional web service request and security issues., (*21)

License

MIT, (*22)

The Versions

18/11 2017

dev-master

9999999-dev

Unified SMS library package for Laravel 5 and PHP (Non-Laravel) to send text messages through multiple swappable drivers.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Victory Osayi

laravel php sms nexmo laravel 5 messaging github open source text messaging betasms routesms routemobile moreify

05/10 2017

v1.0.2

1.0.2.0

Unified SMS library package for Laravel 5 and PHP (Non-Laravel) to send text messages through multiple swappable drivers.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Victory Osayi

laravel php sms nexmo laravel 5 messaging github open source text messaging betasms routesms routemobile moreify

05/10 2017

v1.0.1

1.0.1.0

Unified SMS library package for Laravel 5 and PHP (Non-Laravel) to send text messages through multiple swappable drivers.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Victory Osayi

laravel php sms nexmo laravel 5 messaging github open source text messaging betasms routesms routemobile moreify

05/10 2017

v1.0.0

1.0.0.0

Unified SMS library package for Laravel 5 and PHP (Non-Laravel) to send text messages through multiple swappable drivers.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Victory Osayi

laravel php sms nexmo laravel 5 messaging github open source text messaging betasms routesms routemobile moreify