1. Go to this page and download the library: Download varaai/varasms 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/ */
varaai / varasms example snippets
use VaraSMS\Laravel\Facades\VaraSMS;
// Send to a single recipient
$response = VaraSMS::sendSMS('255738234345', 'Hello World!');
// Send with custom sender ID and reference
$response = VaraSMS::sendSMS(
'255738234345',
'Hello World!',
'MYSENDER',
'ref123'
);
// Send to multiple recipients
$response = VaraSMS::sendSMS(
[
'255738234345',
'255716718040'
],
'Hello everyone!',
'MYSENDER',
'ref123'
);
use VaraSMS\Laravel\Facades\VaraSMS;
// Get all delivery reports
$reports = VaraSMS::getDeliveryReports();
// Get delivery report for a specific message ID
$report = VaraSMS::getDeliveryReport('28089492984101631440');
// Get delivery reports by date range (Deprecated)
$reports = VaraSMS::getDeliveryReportsByDateRange('2024-03-01', '2024-03-15');
use VaraSMS\Laravel\Facades\VaraSMS;
$balance = VaraSMS::getBalance();
use VaraSMS\Laravel\Facades\VaraSMS;
$response = VaraSMS::rechargeCustomer('[email protected]', 5000);
use VaraSMS\Laravel\Facades\VaraSMS;
$response = VaraSMS::deductCustomer('[email protected]', 2000);
use VaraSMS\Laravel\Facades\VaraSMS;
// Get all SMS logs
$logs = VaraSMS::getSMSLogs();
// Get SMS logs with filters
$logs = VaraSMS::getSMSLogs([
'from' => 'NEXTSMS', // Filter by sender ID
'to' => '255716718040', // Filter by recipient number
'sentSince' => '2024-03-01', // Filter messages sent from this date
'sentUntil' => '2024-03-15', // Filter messages sent until this date
'limit' => 500, // Limit number of records (max 500)
'offset' => 20, // Skip first 20 records
'reference' => 'ref123' // Filter by message reference
]);
use VaraSMS\Laravel\Facades\VaraSMS;
class YourTest extends TestCase
{
public function test_sends_sms()
{
VaraSMS::shouldReceive('sendSMS')
->once()
->with('255738234345', 'Test message')
->andReturn([
'success' => true,
'message' => 'Message sent successfully'
]);
// Your test code here
}
}
use VaraSMS\Laravel\Facades\VaraSMS;
// Schedule a one-time SMS
$response = VaraSMS::scheduleSMS(
'255716718040',
'Your message',
'2024-03-25', // Date in Y-m-d format
'14:30', // Time in 24-hour format
'NEXTSMS' // Optional sender ID
);
// Schedule a recurring SMS
$response = VaraSMS::scheduleSMS(
'255716718040',
'Your recurring message',
'2024-03-25', // Initial send date
'14:30', // Time to send
'NEXTSMS', // Optional sender ID
[
'repeat' => 'daily', // hourly, daily, weekly, or monthly
'start_date' => '2024-03-25', // Optional start date for recurring
'end_date' => '2024-04-25' // Optional end date for recurring
]
);
[
'success' => true,
'message' => 'Message scheduled successfully',
'data' => [
'message_id' => '123456',
'to' => '255716718040',
'schedule_time' => '2024-03-25 14:30:00',
'repeat' => 'daily', // Only for recurring messages
'start_date' => '2024-03-25', // Only for recurring messages
'end_date' => '2024-04-25' // Only for recurring messages
]
]
use VaraSMS\Laravel\Facades\VaraSMS;
// Send different messages to different groups of recipients
$response = VaraSMS::sendMultipleMessages([
[
'to' => [
'255716718040',
'255758483019'
],
'text' => 'First message to group 1',
'from' => 'NEXTSMS' // Optional sender ID
],
[
'to' => [
'255758483019',
'255655912841',
'255716718040'
],
'text' => 'Second message to group 2'
// Using default sender ID from config
]
], 'batch123'); // Optional global reference