mirror of
https://github.com/pppscn/SmsForwarder
synced 2025-08-03 01:17:41 +08:00
修复钉钉机器人没启用加签时url拼接错误问题
This commit is contained in:
parent
573e217e4b
commit
3f82b1ae32
@ -38,18 +38,17 @@ public class SenderDingdingMsg {
|
||||
if (token == null || token.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
token = "https://oapi.dingtalk.com/robot/send?access_token=" + token;
|
||||
if (secret != null && !secret.isEmpty()) {
|
||||
Long timestamp = System.currentTimeMillis();
|
||||
|
||||
String stringToSign = timestamp + "\n" + secret;
|
||||
Mac mac = Mac.getInstance("HmacSHA256");
|
||||
mac.init(new SecretKeySpec(secret.getBytes("UTF-8"), "HmacSHA256"));
|
||||
byte[] signData = mac.doFinal(stringToSign.getBytes("UTF-8"));
|
||||
String sign = URLEncoder.encode(new String(Base64.encode(signData, Base64.NO_WRAP)), "UTF-8");
|
||||
token = "https://oapi.dingtalk.com/robot/send?access_token=" + token;
|
||||
token += "×tamp=" + timestamp + "&sign=" + sign;
|
||||
Log.i(TAG, "webhook_token:" + token);
|
||||
|
||||
}
|
||||
|
||||
Map textMsgMap = new HashMap();
|
||||
|
Loading…
x
Reference in New Issue
Block a user