Home  >  Article  >  PHP Framework  >  How thinkphp5 calls the cloud interface to implement the function of sending SMS verification code to retrieve password

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

藏色散人
藏色散人forward
2020-07-01 15:08:183627browse

The following tutorial column of thinkphp framework will 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 parameters apikey, mobile and text.

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!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete