Recently, due to policy reasons, alibaba Cloud, Tencent and other SMS services need to apply for official signatures and templates to use, and the “signature content” should be the full name or short name of the “website name” recorded in the Ministry of Industry and Information Technology, and upload supporting documents, which is a big blow to personal learning

Recommend a short message service platform to everybody herewww.qunfaduanxin.vip/main/index Each account has a limit of two short messages. You can use more accounts, which can generally meet the needs of personal study and use. In addition, the official Java template code is provided as follows:

package com.. thirdtest;import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.URL;
import java.net.URLConnection;

/ * * *@ClassName HttpRequest
 * @Description
 * @Author jinlong
 * @Date 2021/10/11 10:08
 * Version 1.0
 **/
public class HttpRequest {
    /** * Sends a POST request * to the specified URL@param url
     * @param param
     * @param charset
     * @return* /
    public static String sendPost(String url, String param, String charset) {
        OutputStreamWriter out = null;
        BufferedReader in = null;
        String result = "";
        if (null == charset || "".equals(charset)) {
            charset = "UTF-8";
        }
        try {
            URL realUrl = new URL(url);
            // Open the connection with the URL
            URLConnection conn = realUrl.openConnection();
            // Set common request attributes
            conn.setRequestProperty("accept"."* / *");
            conn.setRequestProperty("connection"."Keep-Alive");
            conn.setRequestProperty("user-agent"."Mozilla / 4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)");
            // To send a POST request, the following two lines must be set
            conn.setDoOutput(true);
            conn.setDoInput(true);
            conn.connect();
            // Get the output stream corresponding to the URLConnection object
            out = new OutputStreamWriter(conn.getOutputStream(), charset);
            // Send request parameters
            out.write(param);
            // Flush the output stream buffer
            out.flush();
            out.close();
            // Define the BufferedReader input stream to read the response to the URL
            in = new BufferedReader(
                    new InputStreamReader(conn.getInputStream()));
            String line;
            while ((line = in.readLine()) ! =null) { result += line; }}catch (Exception e) {
            System.err.println("Send POST Error :::: " + e);
            e.printStackTrace();
        }
        // Use the finally block to close the output and input streams
        finally {
            try {
                if(out ! =null) {
                    out.close();
                }
                if (in! =null) {
                    in.close(); }}catch(IOException ex) { ex.printStackTrace(); }}return result;
    }

    // Call mode
    public static void main(String[] args) {

        // Encoding format
        String charset = "UTF-8";

        // Concatenation parameters (concatenation parameters need to be sent as required)
        String postData = "username=3332114904237&password=C74027F754BAB15A83E325204CFCAE190E" +
                "&gwid=f4wy0z32f2&" +
                "Mobile =1898984632514&message= [Jutiworld e-commerce platform] your verification code is: 123456, you are logging in, if not my operation, do not leak.";

        // Interface for sending SMS requests
        String url="http://www.qunfaduanxin.vip/api/send";
        // SMS acknowledgement
        String url1="http://www.qunfaduanxin.vip/api/receive";
        String postData1="username=332311492323047&password=C3274027F754BAB15A3238323E5204CFCAE32190E";

        // Send and assign the result to result, return an XML message, parse the XML information to judge
        String result=HttpRequest.sendPost(url, postData, charset);

        System.out.println("SMS sent successfully, return result:"+result); }}Copy the code

Tests can be sent successfullyFor the return value and parameter description, see the official website.Note:SMS. Webchinese. Cn/default. SHT…The site has a similar feature, which seems to be a better experience, with five free quotas