Skip to content

Latest commit

 

History

History
83 lines (62 loc) · 2.52 KB

README.md

File metadata and controls

83 lines (62 loc) · 2.52 KB

Sparrow SMS Laravel Package

Latest Version Issues Downloads

Sparrow SMS Laravel Package can be used to send SMS via Sparrow SMS or query account's credits.

Getting Started

This package can be installed through Composer.

composer require thebikramlama/sparrow

Publish sparrow.php config file for customization

php artisan vendor:publish --provider="Thebikramlama\Sparrow\SparrowServiceProvider"

How to send an SMS

After the installation is complete, Sparrow alias is generated by default.

Using the default Alias

// Using Default 
use Sparrow;

Send an SMS

$from = 'InfoSms'; // Setting FROM provided by Sparrow
$access_token = 'YOUR_ACCESS_TOKEN'; // Setting Access Token provided by Sparrow

$to = '9801234567'; // Setting Phone Number
$message = 'Test message from Sparrow.'; // Setting Message

// Send the message
$sms_message = Sparrow::send($to, $message, $from, $access_token);
// This will return a pseudo JSON response, you will need to json_decode it.

Getting available Credits

$access_token = 'YOUR_ACCESS_TOKEN'; // Setting Access Token provided by Sparrow

// Query Credits
$credits = Sparrow::credits($access_token);
echo 'Available credits: '. json_decode($credits)->credits_available; // Available credits: 1500

Customization

Make sure you have published sparrow.php config file

php artisan vendor:publish --provider="Thebikramlama\Sparrow\SparrowServiceProvider"

You can find the sparrow.php config file under config/sparrow.php inside your laravel project.

You can edit the file as per your need.

// Your Sparrow SMS Access Token here.
'access_token' => 'YOUR_ACCESS_TOKEN',
// Identity Provided by Sparrow SMS
'from' => 'FROM',

After updating the sparrow.php config file you can call Sparrow methods with lesser arguments.

Example:

$sms_message = Sparrow::send('98081234567', 'Test Messsage'); // From and Access token are optional
$credits = Sparrow::credits(); // Access token is optional

Credits

License

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