Home> PHP Framework> ThinkPHP> body text

How thinkphp5 calls the cloud interface to implement the function of sending SMS verification code to retrieve password

藏色散人
Release: 2020-07-04 13:33:12
forward
3542 people have browsed it

The following tutorial column ofthinkphp frameworkwill introduce to you how thinkphp5 calls the cloud patch interface to realize the function of sending SMS verification code to retrieve the password. I hope it will be helpful to friends in need!

How thinkphp5 calls the cloud interface to implement the function of sending SMS verification code to retrieve password

Idea:

1. The user enters the mobile phone number and requests to obtain the SMS verification code.
2. thinkphp generates the SMS verification code, stores it, and sends the request to Yunpian together with other parameters.
3. Yunpian sends a text message verification code to the designated mobile phone number.
4. The user enters the SMS verification code.
5. thinkphp determines whether the verification is passed based on two conditions: whether the verification code is correct and whether the verification code has expired.

Interface address:https://sms.yunpian.com/v1/sms/send.json.
Use postman and enter the three necessary parametersapikey,mobileandtext.

Example:

1.html file:

##2.js file, implement asynchronous refresh and obtain the returned Information

#3. Create a data table to store the verification code:


4. In the controller Write three methods: (1) Method to create a verification code, send it to the user, and store it in the database, (2) Method to verify whether the verification code is correct and expired, (3) Method to change the password

createcode:

checkcode:


findpwd:


The above is the detailed content of How thinkphp5 calls the cloud interface to implement the function of sending SMS verification code to retrieve password. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!