PHP code example of yoolo-mine / google-authenticator
1. Go to this page and download the library: Download yoolo-mine/google-authenticator 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/ */
yoolo-mine / google-authenticator example snippets
use YooloMine\GoogleAuthenticator\GoogleAuthenticator;
$ga = new GoogleAuthenticator();
$secret = $ga->createSecret();
$uri = $ga->getOtpAuthUri('YourApp', $secret, 'MyCompany');
// Generate QR Code URL using Google Chart API
$qrCodeUrl = 'https://chart.googleapis.com/chart?chs=200x200&cht=qr&chl=' . urlencode($uri);
echo "QR Code URL: " . $qrCodeUrl;
$ga->setCodeLength(8); // 8-digit code / 8 位验证码
html
<img src=" echo $qrCodeUrl;