关于利用webhook(已加签)向钉钉群发送图片问题,来个大佬解惑。
EnterZero
创作者俱乐部成员
请看代码和运行结果,最终版,无奈了,找不出原因
const webhkul="https://oapi.dingtalk.com/robot/send?access_token=2f431c1e4267e763a2ad42f441d40b2912be579276caa24d68ec0dd2119c5ed3"
var timestamp =Math.round(new Date().getTime()).toString();
console.log(timestamp)
var secret ="SEC7f0bd98f701dae340674d46a0282b8589d1f243e80ca8cddb6d59eb5c704a99a";
var stringToSign = timestamp + "\n" + secret;
var sign =Crypto.createHash("sha256",secret).update(stringToSign).digest("hex");
console.log(sign2)
var fullWebhookUrl = webhkul + "×tamp=" + timestamp.toString("base64") + "&sign=" + sign;
console.log(fullWebhookUrl)
const resp2 = HTTP.get("https://img05.tooopen.com/20150401/tooopen_sy_116346892136.jpg")
const body = resp2.binary();
const hash = Crypto.createHash("md5");
const imgBase =body.toString("base64");
console.log(body)
console.log(imgBase)
hash.update(body);
const md5Hash = hash.digest("hex");
HTTP.post(fullWebhookUrl,
{
"msgtype": "image",
"image": {
"base64": imgBase,
"md5": md5Hash
}
}
)
HTTP.post(fullWebhookUrl, {
"msgtype": "text",
"text": {
"content": "这是一个image"
},
});
@金山办公
创作者俱乐部成员
创作者俱乐部成员
创作者俱乐部成员