How validation works in Send SMS
Send SMS is a plugin by Sai Ashirwad Informatia that helps you send SMS easily anywhere over the globe by registering on https://saiashirwad.in (opens new window) their platform.
The plugin does validate the receivers mobile number based on several factors before even sending message directly. This helps identify the junk data very easily and also saves credit as Exceptions are raised before the actual message is sent.
The verification feature is built on-top of authentic source available on Wikipedia (opens new window).
# What it does
This plugin verifies a list of items based on data available from Wikipedia
- List allowed country code
- Based on country code
- It validates the mobile number length, like in India it often is 10 digit, likewise in different countries it maintains the record of length
- Well, it also validates the start numbers, like people can't just enter random number and continue, it verifies the range of number is allowed
Either of the case fails, it throws an exception.
# How it works
This plugin periodically scans the Wikipedia using PHP WebDriver and maintains the data within offline accessible JSON file which is committed within the repository, also available offline for your validation needs.
Check this WebDriver code (opens new window) that generates the JSON for validation purpose.
JSON data by countries (opens new window) you can cross-verify for authenticity.
# Package Features
- Validation of Country Code
- Validation of mobile number by Country Code & known mobile prefix
- Validation of mobile length by Country Code
- Send Transaction SMS
- Send Promotional SMS
- Send OTP over SMS [Under Development]
- Check balance easily
# Installation
composer require saiashirwadinformatia/sendsms
- Register - https://saiashirwad.in (opens new window)
- Retrieve API Key - https://saiashirwad.in/user/#api (opens new window)
# Usage
For security of credentials & identity, Send SMS package reads the .env or rather environment variables due to which the configs will stay secured outside git commits.
# Send SMS
use SaiAshirwadInformatia\SendSMS;
$apiKey = 'API_KEY';
$countryCode = '91';
$senderId = 'ABCDEF'; // PUT your approved Sender-Id
$route = SendSMS::TRANSACTION_ROUTE;
$smsClient = new SendSMS([
'authkey' => $apiKey,
'countryCode' => $countryCode,
'senderId' => $senderId,
'route' => $route
]);
$mobile = '8888888888';
$message = 'Hello, this is your message!';
$countryCode = '91'; // dynamically change country code during each call
$senderId = 'TESTMM'; // dynamically set sender id for each SMS
$dltTemplateId = ''; // This is now mandatory to send SMS in authentic way
$success = $smsClient->send($dltTemplateId, $mobile, $message, $countryCode,
$messageId = $success->getMessage();
echo $messageId;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Check Balance
use SaiAshirwadInformatia\SendSMS;
$apiKey = 'API_KEY';
$smsClient = new SendSMS();
$smsClient->setAuthKey($apiKey);
$balance = $smsClient->checkBalance(SendSMS::TRANSACTION_ROUTE);
echo $balance->getCount(); // returns integer of available SMS credits count
2
3
4
5
6
7
# For Students / Trail Accounts
Free SMS credits (limited) will be given for college project students from India, drop a mail to support@saiashirwad.com
# Read More
https://packagist.org/packages/saiashirwadinformatia/sendsms (opens new window)
Share your feedback or suggestions!