无关风月
2024-07-03 f138375f15c072d10335c20ecec9b35f1da78ee4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package com.ruoyi.study.utils;
 
/**
 * 发送手机验证码工具类
 *
 * @author HJL
 * @version 1.0
 * @since 2024-05-17 14:31
 */
public class SendMsgUtils {
 
    public static final String UID = "EUhello";
    public static final String KEY = "6D05DE2FF1294C81CEF25E0862448D11";
 
    public static String sendMessage(String smsMob, String smsText) {
//        PostMethod post = new PostMethod("https://utf8api.smschinese.cn/");
//        try {
//            HttpClient client = new HttpClient();
//            post.addRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");//在头文件中设置转码
//            NameValuePair[] data = {new NameValuePair("Uid", UID), new NameValuePair("Key", KEY), new NameValuePair("smsMob", smsMob), new NameValuePair("smsText", smsText)};
//            post.setRequestBody(data);
//            client.executeMethod(post);
//            Header[] headers = post.getResponseHeaders();
//            int statusCode = post.getStatusCode();
//            System.out.println("statusCode:" + statusCode); //HTTP状态码
//
//            for (Header h : headers) {
//                System.out.println(h.toString());
//            }
//            String result = new String(post.getResponseBodyAsString().getBytes("utf-8"));
//            System.out.println(result);  //打印返回消息状态
//            return result;
//        } catch (Exception e) {
//            e.printStackTrace();
//        } finally {
//            // 关流
//            post.releaseConnection();
//        }
        return null;
    }
 
}