hi sir, my timezone is gmt+8, i modify the timezone and pass the param to $timeslice, but i keep keyin the code and keep cant match the code with my phone, anything i did it wrong? thank you.
I guess the problem is that you give the current timestamp to the methods getCode() and verifyCode(). You need to give it the "time slice", which is a timestamp devided by 30... Maybe it works then?
hi sir, my timezone is gmt+8, i modify the timezone and pass the param to $timeslice, but i keep keyin the code and keep cant match the code with my phone, anything i did it wrong? thank you.
<?php
require_once '../PHPGangsta/GoogleAuthenticator.php';
$timezone = 8; //(GMT +8:00) Asia $unixtimestamp = time() + 3600*$timezone;
$ga = new PHPGangsta_GoogleAuthenticator();
$secret = $ga->createSecret(); echo "Secret is: ".$secret."\n\n";
$qrCodeUrl = $ga->getQRCodeGoogleUrl('Blog', $secret); echo "Google Charts URL for the QR-Code: ".$qrCodeUrl."\n\n";
$oneCode = $ga->getCode($secret,$unixtimestamp); echo "Checking Code '$oneCode' and Secret '$secret':\n\n";
$code=$_POST['txtCode']; echo $code."
";
$checkResult = $ga->verifyCode($secret, $code,30,$unixtimestamp); // 2 = 2*30sec clock tolerance if ($checkResult) { echo 'OK'; } else { echo 'FAILED'; }
?>