Skip to content

Bring SMSFactor API features into your Laravel application

Notifications You must be signed in to change notification settings

smsfactor/smsfactor-laravel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SMS API Package for Laravel

The Laravel Service Provider that allows you to use SMSFactor PHP Client library.

In order to use it, make sure to have an account. You can register here. Once your account is created, you need to generate your first API token. You can find the complete documentation of our API here.

Installation

We recommend using Composer to install the PHP client library to your project.

composer require smsfactor/smsfactor-laravel

Laravel 5.5+

If you're using Laravel 5.5 or above, the package will automatically register the SMSFactor provider and facades.

Laravel 5.4 and below

Add SMSFactor\Laravel\SMSFactorServiceProvider to the providers array in your config/app.php:

'providers' => [
    // Other service providers...
    SMSFactor\Laravel\SMSFactorServiceProvider::class,
],

If you want to use the a facade interface, you can use any of them depending on your need:

use SMSFactor\Laravel\Facade\Account;
use SMSFactor\Laravel\Facade\Campaign;
use SMSFactor\Laravel\Facade\ContactList;
use SMSFactor\Laravel\Facade\Message;
use SMSFactor\Laravel\Facade\Webhook;
use SMSFactor\Laravel\Facade\Token;

Or add any alias in your config/app.php:

'aliases' => [
    ...
    'SMSFactor' => SMSFactor\Laravel\Facade\Account::class,
    'SMSFactor' => SMSFactor\Laravel\Facade\Campaign::class,
    'SMSFactor' => SMSFactor\Laravel\Facade\ContactList::class,
    'SMSFactor' => SMSFactor\Laravel\Facade\Message::class,
    'SMSFactor' => SMSFactor\Laravel\Facade\Webhook::class,
    'SMSFactor' => SMSFactor\Laravel\Facade\Token::class,
],

Configuration

You can use artisan vendor:publish to copy the distribution configuration file to your app's config directory:

php artisan vendor:publish

Then update config/smsfactor.php with your token.

Usage

To use the SMSFactor Client Library you can use the facades, or request an instance from the service container:

$response = Message::send([
	'to' => '33600000000',
	'text' => 'Have you ever danced with the devil in the pale moonlight ?'
]);
print_r($response->getJson()); //In case you don't receive your text, printing the API response might be useful

or

$account = app('SMSFactor\Message');
$response = $account->send([
	'to' => '33600000000',
	'text' => 'Have you ever danced with the devil in the pale moonlight ?'
]);
print_r($response->getJson());

About

Bring SMSFactor API features into your Laravel application

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages