uflixdesign/sms-api-sdk

SDK for UFLIX DESIGN - SMS Gateway

1.1 2020-01-31 18:54 UTC

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.

ConstantValueReliablityDescription
ROUTE_PROMOpromo~70%Promotional Route, will never deliver even to DND registered phone numbers.
ROUTE_PROMODNDpromodnd~80%Promotional Route, but will deliver even to DND registered phone numbers.
ROUTE_TRANStrans~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

ParameterTypeDefaultDescription
$userstringrequiredGive the account username
$passwordstringrequiredGive the account password
$configarrayoptional []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
ParameterTypeDefaultDescription
$getExceptionbooleanoptional falseIf 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
ParameterTypeDefaultDescription
$numbersstring | arrayrequiredSingle Phone number if string, for multiple use array.
$messagestringrequiredSMS body message to be sent.
$routestringoptionalRoute 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
ParameterTypeDefaultDescription
$actionstringrequiredMax length: 32 chars. An named action, that describes what's the OTP for.
$numberstringrequiredPhone Number to send the OTP.
$messagestringoptional Default: ''A message template use {{code}} to replace with autogenerated OTP. If not specified, a default template will be used.
$ttlintegeroptional Default: 5Time 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
ParameterTypeDefaultDescription
$actionstringrequiredMax length: 32 chars. An named action, that describes the OTP for.
$numberstringrequiredPhone Number where the OTP was sent before.
$codestringrequiredOTP that was delivered to the mobile phone.

Returns true if OTP is verified successfully, false otherwise