9 changed files with 146 additions and 2 deletions
@ -0,0 +1,48 @@ |
|||
package com.qs.serve.common.util; |
|||
|
|||
import cn.hutool.crypto.digest.DigestUtil; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.io.UnsupportedEncodingException; |
|||
import java.net.URLEncoder; |
|||
|
|||
/** |
|||
* @author YenHex |
|||
* @since 2024/1/26 |
|||
*/ |
|||
@Slf4j |
|||
@Service |
|||
public class TianYiYunSmsUtil { |
|||
|
|||
private final static String url = "http://sms.189ek.com/yktsms/send?"; |
|||
|
|||
private final static String appId = "WIgWyCFn4DnHLtjKBIXBVyZbGevFg3J4"; |
|||
|
|||
private final static String appKey = "bjfsZlF01OZPUzyiCLSFOrOOnfsZhYZJ"; |
|||
|
|||
public static void sendMsg(String code){ |
|||
send("13286630016,15989082884,15913696250",code); |
|||
} |
|||
|
|||
public static void send(String phone,String code){ |
|||
//需要发送的手机号(多个号码以英文逗号 “,”分隔) 一次性最多 100 个号码
|
|||
String mobiles = phone; |
|||
String content = "【嘉士利】尊敬的用户,您预约来访已成功,"+code; |
|||
String sign = DigestUtil.md5Hex(appId+mobiles+content+appKey); |
|||
try { |
|||
String msg = URLEncoder.encode(content,"utf-8"); |
|||
String params = "appid="+ appId + |
|||
"&mobile="+ mobiles + |
|||
"&msg=" + msg + |
|||
"&sign=" + sign + |
|||
"&extPort="; |
|||
String result = HttpUtil.doPost(url+params,"{}",null); |
|||
log.debug("sms result = > {}",result); |
|||
} catch (UnsupportedEncodingException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
} |
|||
|
|||
} |
Loading…
Reference in new issue