aqlx86/sms-otp

使用iSMS网关为Laravel 5提供的短信OTP。

v1.3.1 2018-09-30 14:21 UTC

This package is auto-updated.

Last update: 2024-08-29 04:59:02 UTC


README

Laravel 5的短信OTP。默认情况下,此OTP使用iSMS作为短信提供商。

安装

将sms-otp添加到您的composer.json文件中

composer.phar require "aqlx86/sms-otp"

将服务提供者添加到您的Laravel应用配置config/app.php中

SMSOTP\SMSOTPServiceProvider::class

发布

php artisan vendor:publish --provider="SMSOTP\SMSOTPServiceProvider"
php artisan migrate

用法

要发送OTP,请记住包含:code,这将替换为实际代码。

$sender = app()->make(OTPSender::class);
$sender->send('6399512345678', 'holy shit your otp code is :code');

要验证OTP代码

$verifier = app()->make(OTPVerifier::class);
$verifier->verify('6399512345678', 'A44E8');

扩展

使用其他短信提供商

创建您的短信提供商

class CustomSMSProvider implemnts SMSOTP\Contract\SMSGateway
{
    public function send($number, $message)
    {
        // your implemention
    }
}

更新配置 config/smsotp.php

'sms' => CustomSMSProvider::class,

生成自己的OTP代码

与创建自己的短信提供商相同。