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