Java implements SMS verification code

Disclaimer: The materials used in this column are written by VIP students of Kaige Academy. Students have the right to remain anonymous and have the right to final interpretation of the article. Kaige Academy aims to promote VIP students to learn from each other based on public notes.

SMS verification code

SMS verification codes are all calling some interfaces to send SMS messages. SMS verification codes are most widely used in operations such as login and registration. This section of this article demonstrates how to use Java to create a simple SMS verification code login.

What I am demonstrating here is the SMS interface of aggregated data (not advertisement), because the interface call of aggregated data is more convenient and simple, so first of all, we must first apply for a SMS interface API in aggregated data:

image

image

You will be required to perform real-name authentication when applying. If you do not want to be authenticated, you can skip the authentication.

After applying for the SMS API, enter the following interface and click "Template":

image

You need to apply for a SMS template first, and define the template content according to your own needs (read the template rules at the bottom of this page before defining):

image

After submitting for review, you can see the template list and template review status at the bottom of this page:

image

Then click "My Data", and then click "Interface" in the SMS API service:

image

The calling instructions of the interface are all on this page, and the API needs to be called according to the rules here:

image

After the SMS template is applied, you can use this API. The following shows how to use Java to call this API and make a simple SMS verification code login: First, the index.jsp code of the page:

image

The class used to call the SMS interface:

image

Servlet that handles sending captcha requests:

image

image

Finally, the Servlet that handles the login business:

image

image

image

operation result:

image

Received verification code:

image

Enter the verification code to log in:

image

Console prints:

image

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326443075&siteId=291194637