How validation works in Send SMS

4/12/2020 phppluginslibraries

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

  1. List allowed country code
  2. Based on country code
    1. It validates the mobile number length, like in India it often is 10 digit, likewise in different countries it maintains the record of length
    2. 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

  1. Validation of Country Code
  2. Validation of mobile number by Country Code & known mobile prefix
  3. Validation of mobile length by Country Code
  4. Send Transaction SMS
  5. Send Promotional SMS
  6. Send OTP over SMS [Under Development]
  7. Check balance easily

# Installation

composer require saiashirwadinformatia/sendsms
1
  1. Register - https://saiashirwad.in (opens new window)
  2. 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;
1
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
1
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 [email protected]

# Read More

https://packagist.org/packages/saiashirwadinformatia/sendsms (opens new window)

Share your feedback or suggestions!