PHP code example of fanwei / googleauthenticator
1. Go to this page and download the library: Download fanwei/googleauthenticator 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/ */
fanwei / googleauthenticator example snippets
use Fanwei\GoogleAuthenticator\GoogleAuthenticator;
$ga = new GoogleAuthenticator();
// 创建
$secret = $ga->createSecret();
// 获取 code
$code = $ga->getCode($secret);
// 验证 code
$res = $ga->verifyCode($secret, $code);
// 获取二维码字符串
$qrcodeString = $ga->getQrcodeString($secret, 'GoogleAuthenticator');