新版仿ok交易所-后端
1
zyy
2025-12-18 2462671fc9f457a50eb584d852e6273aec2a5a37
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package com.yami.trading.common.manager.sms;
 
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.http.Header;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.json.JSONUtil;
import org.springframework.stereotype.Component;
 
import java.time.LocalDateTime;
import java.time.ZoneId;
 
@Component
public class BUKASmsUtils {
 
    private static final String baseUrl = "https://api.onbuka.com/v3/sendSms";
    private static final String apiKey = "M1OMJVgD";
    private static final String apiPwd = "IdYtbSHH";
    private static final String appId = "PC0S982D";
    private static final String senderId = "56465123126";
 
    public void sendSms(String numbers,String message){
        HttpRequest request = HttpRequest.post(baseUrl);
        //generate md5 key
        final String datetime = String.valueOf(LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().getEpochSecond());
        final String sign = SecureUtil.md5(apiKey.concat(apiPwd).concat(datetime));
 
        request.header(Header.CONNECTION, "Keep-Alive")
                .header(Header.CONTENT_TYPE, "application/json;charset=UTF-8")
                .header("Sign", sign)
                .header("Timestamp", datetime)
                .header("Api-Key", apiKey);
 
 
        final String params = JSONUtil.createObj()
                .set("appId", appId)
                .set("numbers", numbers)
                .set("content", message)
                //.set("senderId", senderId)
                .toString();
 
        HttpResponse response = request.body(params).execute();
        if (response.isOk()) {
            String result = response.body();
            System.out.println(result);
        }
    }
 
 
    public static void main(String[] args) {
        BUKASmsUtils sender = new BUKASmsUtils();
 
        try {
            sender.sendSms("12133131611", "Your verification code is 123456.");
            // 输出响应结果
            //String responseWithChinese = StringEscapeUtils.unescapeJava(response);
            //System.out.println("中文发送结果: " + responseWithChinese);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}