PHP code example of thebikramlama / sparrow

1. Go to this page and download the library: Download thebikramlama/sparrow library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

thebikramlama / sparrow example snippets


// 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

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

$sms_message = Sparrow::send('98081234567', 'Test Messsage'); // From and Access token are optional
$credits = Sparrow::credits(); // Access token is optional
bash
php artisan vendor:publish --provider="Thebikramlama\Sparrow\SparrowServiceProvider"
bash
php artisan vendor:publish --provider="Thebikramlama\Sparrow\SparrowServiceProvider"