-
OK SMS operators
Clouds I used here, but we can also use other.
- First, register yourself an account, and then find the
- Click Start access, complete novice boot process.
- The second part of the signature and the template must be filled, so similar to me to fill in the following
It is noteworthy that this template and the time you have to use easy-sms
when the package is set and the content of the message must be exactly the same, or will be error.
There is got to remember to get APIKEY. Configure the interface calls the env years.
2. Install easy-sms
Package
- With this package, you can quickly achieve short message sending function.
Since this component is not Laravel of ServiceProvider
, for ease of use, we can package it themselves.
- First, the increase in the config directory
easysms.php
files
In config / easysms.php fill in the following.
Then create a ServiceProvider
Modify the file app / providers / EasySmsServiceProvider.php
Finally, config/app.php
the providers
increase in service created just write in,App\Providers\EasySmsServiceProvider::class,
3. Create routes and the corresponding controller
Firstly create a route, we need an ajax request SMS verification codes, and a logical way to confirm registration, as follows
After the route is created, with direct command generates a controller
Then write directly on the inside register
and ajaxregister
method of
- Code logic
Modify the file
app / Home / VerificationCodesController.php
At this time, users will be able to receive text messages, and the front end should save the key
delivery time, submit the registration form to the background, whether the judge has expired. Here's judgment has expired, whether the error code.
The above hash_equals
is possible to prevent timing attacks string comparison ~
If you need to obtain solution ideas relevant source notes, the problem may be the group to explore: