PHP code example of eagleeye / otp
1. Go to this page and download the library: Download eagleeye/otp library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
eagleeye / otp example snippets
//Facade accessor public function
public function get(String $key)
{
//processing...
}
$otp = OTP::get('usertoken');
echo $otp;
// 20220317221648
// https://example/url
"267958"
//Facade accessor public function
public function interval(String $key)
{
//processing...
}
$otp = OTP::interval('usertoken');
echo $otp;
// 20220317221648
// https://example/url
array:2 [▼
"expired" => false,
"remaining" => "00 00:01:49" //Remaining time of expiration
]
$otp = OTP::interval('usertoken');
echo $otp;
// 20220317221648
// https://example/url
array:2 [▼
"expired" => true,
"otp" => "282561", //New otp
"remaining" => "00 00:01:49" //Remaining time of expiration
]
//Facade accessor public function
public function action(String $key,Callable $callback)
{
//processing...
}
$otp = OTP::action('usertoken',function($otp){
//Sms::send('+8801*******',$otp);
});
echo $otp;
// 20220317221648
// https://example/url
"267958"
//Facade accessor public function
public function intervalaction(String $key,Callable $callback)
{
//processing...
}
$otp = OTP::intervalaction('usertoken',function($otp){
//Sms::send('+8801*******',$otp);
});
echo $otp;
// 20220317221648
// https://example/url
array:2 [▼
"expired" => false
"remaining" => "00 00:01:49" //Remaining time of expiration
]
$otp = OTP::intervalaction('usertoken',function($otp){
//Sms::send('+8801*******',$otp);
});
echo $otp;
// 20220317221648
// https://example/url
array:2 [▼
"expired" => true
"otp" => "282561" //New otp
"remaining" => "00 00:01:49" //Remaining time of expiration
]
//Facade accessor public function
public function verify($key,$otp)
{
//processing...
}
$result=OTP::verify('usertoken','12345678');
echo $result;
"true"
//Facade accessor public function
public function readonly($options=nullable)
{
//processing...
}
$result=OTP::readonly(['prefix'=>'sn','length'=>15,'case'=>'upper','type'=>'alphabetic']);
echo $result;
// 20220331221403
// http://otp.test/
"sn-ISUQXTFPQYJIMSR"
bash
php artisan vendor:publish --provider="Eagleeye\Otp\OtpServiceProvider" --tag=config
bash
php artisan vendor:publish --provider="Eagleeye\Otp\OtpServiceProvider" --tag=migrations