PHP code example of clef / instant2fa
1. Go to this page and download the library: Download clef/instant2fa 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/ */
clef / instant2fa example snippets
$instant2fa = new \Instant2FA\Instant2FA([
'access_key' => ACCESS_KEY,
'access_secret' => ACCESS_SECRET
]);
$distinct_id = "A_UNIQUE_ID_FOR_A_GIVEN_USER";
// To show hosted 2FA settings:
$hosted_page_url = $instant2fa->create_settings($distinct_id);
// To show a hosted verification page:
try {
$hosted_page_url = $instant2fa->create_verification($distinct_id);
// Redirect to 2FA verification page
} catch (\Instant2FA\Error\MFANotEnabled $e) {
// Log the user in as normal
}
// To see whether a user successfully completed 2FA verification:
$succeeded = $instant2fa->confirm_verification($distinct_id, $request->input('instant2faToken'));