From 203abdf7b779e6f8f226e147fa40516b77143f14 Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期二, 17 十二月 2024 12:16:03 +0800 Subject: [PATCH] 修改第三方账号 --- UserAHTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/SmsUtil.java | 40 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 40 insertions(+), 0 deletions(-) diff --git a/UserAHTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/SmsUtil.java b/UserAHTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/SmsUtil.java new file mode 100644 index 0000000..5b5a689 --- /dev/null +++ b/UserAHTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/SmsUtil.java @@ -0,0 +1,40 @@ +package com.stylefeng.guns.modular.system.util; + +import cn.hutool.crypto.SecureUtil; +import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpResponse; +import cn.hutool.http.HttpUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; + +/** + * @author zhibing.pu + * @Date 2024/12/17 9:25 + */ +public class SmsUtil { + + + /** + * 发送短信 + * https://doc.zthysms.com/web/#/1/14 + * @param mobile + * @param content + */ + public static void sendZTHYSms(String mobile, String content){ + HttpRequest post = HttpUtil.createPost("https://api-shss.zthysms.com/v2/sendSms"); + post.contentType("application/json"); + JSONObject body = new JSONObject(); + Long tKey = System.currentTimeMillis() / 1000; + body.put("username", "GZAHKJhy"); + body.put("password", SecureUtil.md5(SecureUtil.md5("@zLa@cB0") + tKey)); + body.put("tKey", tKey); + body.put("mobile", mobile); + body.put("content", "【安合出行】" + content); + post.body(body.toJSONString()); + HttpResponse execute = post.execute(); + JSONObject result = JSON.parseObject(execute.body()); + if(200 != result.getInteger("code")){ + throw new RuntimeException(result.getString("msg")); + } + } +} -- Gitblit v1.7.1