uflixdesign / sms-api-sdk
SDK for UFLIX DESIGN - SMS Gateway
Requires
- ext-curl: *
This package is auto-updated.
Last update: 2024-05-05 01:24:46 UTC
README
SDK for UFLIX DESIGN - SMS Gateway.
Routes.
SMS can be sent via various routes, as per requirement & availability choose one of the below whenever you require to specify a route.
Constant | Value | Reliablity | Description |
---|---|---|---|
ROUTE_PROMO | promo | ~70% | Promotional Route, will never deliver even to DND registered phone numbers. |
ROUTE_PROMODND | promodnd | ~80% | Promotional Route, but will deliver even to DND registered phone numbers. |
ROUTE_TRANS | trans | ~99% | Transactional Route, will deliver to DND registered phone numbers |
For any request you have to create an instance of the SMS Gateway Client.
$sms = new UFXDSMSAPI\\Client($user, $pass, $config);
Parameters
Parameter | Type | Default | Description |
---|---|---|---|
$user | string | required | Give the account username |
$password | string | required | Give the account password |
$config | array | optional [] | The SDK uses GuzzleHttp\\Guzzle to request the HTTP API, this options just overrides the default options. For more information check Guzzle Request Options. |
Get Account Balance
This method is used to get the sms balances of the account.
$sms->balance(): object|null
Returns null on failure, if successful, returns object with balance info.
Check if SMS Server is up & running.
This method is used to check if our SMS Server is up and running properly.
$sms->APIStatus($getException): boolean
Parameter | Type | Default | Description |
---|---|---|---|
$getException | boolean | optional false | If set to true the method throws exception instead returning a false on error. |
Returns true on success, false on failure, if $getException
is set to false
. On failure the method will throw exception if $getException
is set to true
.
Send a plain SMS.
This method is used to send SMS through our SMS Gateway.
$sms->sendSMS($numbers, $message, $route): object
Parameter | Type | Default | Description |
---|---|---|---|
$numbers | string | array | required | Single Phone number if string, for multiple use array. |
$message | string | required | SMS body message to be sent. |
$route | string | optional | Route through which the SMS will be sent. Use Class Constants for route available within the class |
Returns an object of the status.
Send OTP.
Send OTP (one time password) to a number for verification later on. Note, that you don't need to generate to store the OTP into your database. All the hardwork is done within our API.
All OTP will have a time frame for validation here given through $ttl
. Our API is smart enough to verify OTP even if not delivered in order. So, if a user sends 2 or more OTP but they are not delivered in order, any one of the OTP can be used to verify.
$sms->sendOTP($action, $number, $message, $ttl): boolean
Parameter | Type | Default | Description |
---|---|---|---|
$action | string | required | Max length: 32 chars. An named action, that describes what's the OTP for. |
$number | string | required | Phone Number to send the OTP. |
$message | string | optional Default: '' | A message template use {{code}} to replace with autogenerated OTP. If not specified, a default template will be used. |
$ttl | integer | optional Default: 5 | Time To Live. How much time an OTP is valid for verification. Value is given in minutes. |
Returns true
on Success, false
otherwise.
Verify OTP.
Verify otp sent to the number where you've sent OTP previously.
The action
defines what is the OTP for, so the action should be the same as what used when sending the OTP. This way, a single application can have multiple places for OTP verification and each place will use different action name. Example: login
, cod
etc.
$sms->verifyOTP($action, $number, $code): boolean
Parameter | Type | Default | Description |
---|---|---|---|
$action | string | required | Max length: 32 chars. An named action, that describes the OTP for. |
$number | string | required | Phone Number where the OTP was sent before. |
$code | string | required | OTP that was delivered to the mobile phone. |
Returns true
if OTP is verified successfully, false
otherwise