Skip to content
This repository has been archived by the owner on Apr 20, 2022. It is now read-only.

GlobalSmartOTP/php-lib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DEPRECATED! Please check MessageWay

DEPRECATED


gsOTP

Latest Version on Packagist Total Downloads Swagger Global Smart OTP 🇮🇷

GlobalSmartOTP PHP SDK

A PHP SDK for the GlobalSmartOTP API.

Available Methods

  • SMS (Iran: 2000, 3000, 9000)
  • Messenger
  • IVR

Requirements

  • PHP 7.4 or higher
  • ext-curl
  • ext-json
  • composer

Installation

with Composer

$ composer require globalsmartotp/php-lib

Require

require dirname(__FILE__) . '/../vendor/autoload.php';
use GlobalSmartOTP\Api\OTPHandler;

// Get apiKey from https://gsotp.com/dashboard/document/
$apiKey = "";
$mobile = "";
$templateID = 3;

without Composer

$ git clone git@github.com:GlobalSmartOTP/php-lib.git

Require

require dirname(__FILE__) . '/php-lib/src/OTPHandler.php';
use GlobalSmartOTP\Api\OTPHandler;

// Get apiKey from https://gsotp.com/dashboard/document/
$apiKey = "";
$mobile = "";
$templateID = 3;

Send OTP

By SMS

try {
	$referenceID = OTPHandler::BySms($apiKey, $mobile, $templateID);
	echo "ReferenceID: {$referenceID}";
} catch (\Exception $e) {
	echo $e->getMessage();
}

By Messenger

$provider = 'whatsapp'; // whatsapp, gap
try {
	$referenceID = OTPHandler::ByMessenger($apiKey, $mobile, $templateID, 'whatsapp');
	echo "ReferenceID: {$referenceID}";
} catch (\Exception $e) {
	echo $e->getMessage();
}

By IVR

$templateID = 2;
try {
	$referenceID = OTPHandler::ByIvr($apiKey, $mobile, $templateID);
	echo "ReferenceID: {$referenceID}";
} catch (\Exception $e) {
	echo $e->getMessage();
}

Verify

try {
	OTPHandler::isVerify($apiKey, $mobile, $otp);
	echo "OTP is verified";
} catch (\Exception $e) {
	echo $e->getMessage();
}

Status

try {
	$gsOTP = OTPHandler::checkStatus($apiKey, $referenceID);
	echo "OTPStatus: " . $gsOTP->getOTPStatus() . PHP_EOL;
	echo "OTPVerified: " . $gsOTP->isOTPVerified() . PHP_EOL;
	echo "OTPMethod: " . $gsOTP->getOTPMethod() . PHP_EOL;
} catch (\Exception $e) {
	echo "Error:" . $e->getMessage();
}

License

MIT