PHP code example of kiranbhor / laravel-otp-validate

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

    

kiranbhor / laravel-otp-validate example snippets


Ferdous\OtpValidator\OtpValidatorServiceProvider::class

'OtpValidator' => Ferdous\OtpValidator\OtpValidatorServiceProvider::class

namespace App\Http\Controllers;

use Ferdous\OtpValidator\Object\OtpRequestObject;
use Ferdous\OtpValidator\OtpValidator;
use Ferdous\OtpValidator\Object\OtpValidateRequestObject;

class OtpController extends Controller
{
    /**
     * @return array
     */
    public function requestForOtp()
    {
        return OtpValidator::requestOtp(
            new OtpRequestObject('1432', 'buy-shirt', '01711084714', '[email protected]')
        );
    }

    /**
     * @param Request $request
     * @return array
     */
    public function validateOtp(Request $request)
    {
        $uniqId = $request->input('uniqueId');
        $otp = $request->input('otp');
        return OtpValidator::validateOtp(
            new OtpValidateRequestObject($uniqId,$otp)
        );
    }

    /**
     * @param Request $request
     * @return array
     */
    public function resendOtp(Request $request)
    {
        $uniqueId = $request->input('uniqueId');
        return OtpValidator::resendOtp($uniqueId);
    }

}

'smsc' => [
    'url' => env('OTP_SMSC_URL'),
    'method' => env('OTP_SMSC_METHOD', 'GET'),
    'add_code' => env('OTP_COUNTRY_CODE',null),
    'json' => env('OTP_SMSC_OVER_JSON',1),
    'headers' => [],
    'params' => [
        'send_to_param_name' => env('OTP_SMSC_PARAM_TO_NAME','number'),
        'msg_param_name' => env('OTP_SMSC_PARAM_MSG_NAME','msg'),
        'others' => [
            'user' => env('OTP_SMSC_USER'),
            'password' => env('OTP_SMSC_PASS'),
            'unicode' => 1
        ],
    ]
];

'smsc' => [
    'url' => env('OTP_SMSC_URL'),
    'method' => env('OTP_SMSC_METHOD', 'GET'),
    'add_code' => env('OTP_COUNTRY_CODE',null),
    'json' => env('OTP_SMSC_OVER_JSON',1),
    'headers' => [],
    'params' => [
        'send_to_param_name' => env('OTP_SMSC_PARAM_TO_NAME','number'),
        'msg_param_name' => env('OTP_SMSC_PARAM_MSG_NAME','msg'),
        'others' => [
            'username' => env('OTP_SMSC_USER'),
            'password' => env('OTP_SMSC_PASS'),
            'from' => 'InfoSMS',
            'flash' => true
        ],
    ]
];

'smsc' => [
        'url' => env('OTP_SMSC_URL'),
        'method' => env('OTP_SMSC_METHOD', 'GET'),
        'add_code' => env('OTP_COUNTRY_CODE',null),
        'json' => env('OTP_SMSC_OVER_JSON',1),
        'headers' => [],
        'params' => [
            'send_to_param_name' => env('OTP_SMSC_PARAM_TO_NAME','number'),
            'msg_param_name' => env('OTP_SMSC_PARAM_MSG_NAME','msg'),
            'others' => [
                'authkey' => 'YourAuthKey',
                'sender' => 'YourSenderId',
                'route' => '1',
                'country' => '88',
            ],
        ],
        'wrapper' => 'sms',
    ];

php artisan vendor:publish --provider="Ferdous\OtpValidator\OtpValidatorServiceProvider"

php artisan migrate

OTP_SMSC_URL='http://clients.muthofun.com:8901/esmsgw/sendsms.jsp?'
OTP_SMSC_METHOD='GET'
OTP_COUNTRY_CODE='88'
OTP_SMSC_OVER_JSON=0
OTP_SMSC_PARAM_TO_NAME='mobiles'
OTP_SMSC_PARAM_MSG_NAME='sms'
OTP_SMSC_USER='YourUserName'
OTP_SMSC_PASS='YourPassWord'

OTP_SMSC_URL='https://{baseUrl}/sms/1/text/query?'
OTP_SMSC_METHOD='GET'
OTP_COUNTRY_CODE='88'
OTP_SMSC_OVER_JSON=0
OTP_SMSC_PARAM_TO_NAME='to'
OTP_SMSC_PARAM_MSG_NAME='text'
OTP_SMSC_USER='YourUserName'
OTP_SMSC_PASS='YourPassWord'