PHP code example of xddesigners / otp-authenticator

1. Go to this page and download the library: Download xddesigners/otp-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/ */

    

xddesigners / otp-authenticator example snippets


public function otpSendTo()
{
    return new OTPSendTo($member->Email, ['additional' => 'data']);
}

class MySendProvider extends XD\OTPAuthenticator\Providers\SendProvider
{
/**
     * Send the code
     */
    public function send($code, $to): bool
    {}

    /**
     * Validate the send to address
     */
    public function validate($to, $data): bool
    {}
    
    /**
     * Add a regex to validate the input on the frond end
     */
    public function getFieldValidate(): string
    {}

    /**
     * method to check if the provider is properly set up
     */
    public function enabled(): bool
    {}

    /**
     * Obfuscate the sent to address.
     * So a user has a way to verify the sent address is correct 
     * but in a way an unallowed user couldn't make out the complete address
     */
    public function obfuscateTo($to): string
    {}
    
    /**
     * Register the field type to switch to.
     * Accepts phone, email, or text
     */
    public function getFieldType(): string
    {}

    /**
     * Register the field label
     */
    public function getFieldLabel(): string
    {}
}