项目作者: aqlx86

项目描述 :
SMS OTP for Laravel 5
高级语言: PHP
项目地址: git://github.com/aqlx86/sms-otp.git
创建时间: 2017-05-25T08:05:11Z
项目社区:https://github.com/aqlx86/sms-otp

开源协议:MIT License

下载


Introduction

SMS OTP for Laravel 5. By default this uses iSMS as SMS provider.

Installation

Add sms-otp to your composer.json file:

  1. composer.phar require "aqlx86/sms-otp"

Add the service provider to your Laravel application config/app.php:

  1. SMSOTP\SMSOTPServiceProvider::class

Publish

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

Usage

To send OTP, remember to include :code this will be replaced with the actual code.

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

To verify OTP code

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

Extending

Using other SMS provider

Create your sms provider

  1. class CustomSMSProvider implemnts SMSOTP\Contract\SMSGateway
  2. {
  3. public function send($number, $message)
  4. {
  5. // your implemention
  6. }
  7. }

Update configuration config/smsotp.php

  1. 'sms' => CustomSMSProvider::class,

Generating your own OTP code

Do the same as creating your own SMS provider.