Sparrow SMS Laravel Package can be used to send SMS via Sparrow SMS or query account's credits.
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"
After the installation is complete, Sparrow
alias is generated by default.
// Using Default
use Sparrow;
$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.
$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
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
The MIT License (MIT). Please see License File for more information.