DEPRECATED! Please check MessageWay
A PHP SDK for the GlobalSmartOTP API.
- PHP 7.4 or higher
- ext-curl
- ext-json
- composer
$ composer require globalsmartotp/php-lib
require dirname(__FILE__) . '/../vendor/autoload.php';
use GlobalSmartOTP\Api\OTPHandler;
// Get apiKey from https://gsotp.com/dashboard/document/
$apiKey = "";
$mobile = "";
$templateID = 3;
$ git clone git@github.com:GlobalSmartOTP/php-lib.git
require dirname(__FILE__) . '/php-lib/src/OTPHandler.php';
use GlobalSmartOTP\Api\OTPHandler;
// Get apiKey from https://gsotp.com/dashboard/document/
$apiKey = "";
$mobile = "";
$templateID = 3;
try {
$referenceID = OTPHandler::BySms($apiKey, $mobile, $templateID);
echo "ReferenceID: {$referenceID}";
} catch (\Exception $e) {
echo $e->getMessage();
}
$provider = 'whatsapp'; // whatsapp, gap
try {
$referenceID = OTPHandler::ByMessenger($apiKey, $mobile, $templateID, 'whatsapp');
echo "ReferenceID: {$referenceID}";
} catch (\Exception $e) {
echo $e->getMessage();
}
$templateID = 2;
try {
$referenceID = OTPHandler::ByIvr($apiKey, $mobile, $templateID);
echo "ReferenceID: {$referenceID}";
} catch (\Exception $e) {
echo $e->getMessage();
}
try {
OTPHandler::isVerify($apiKey, $mobile, $otp);
echo "OTP is verified";
} catch (\Exception $e) {
echo $e->getMessage();
}
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();
}
MIT