Python 官方文档:入门教程 => 点击学习
目录一、获取企业微信群机器人 WEBhook 地址二、Webhook支持消息类型三、Webhook使用配置1.添加Maven依赖2.配置webhook地址api3.注入Message
业务需要在企业微信推送告警监控或者定时提醒业务,就可以使用企业微信自带的机器人工具Webhook reboot作为消息的发起者!
打开手机端企业微信App,打开一个内部群聊,点击右上角图标进入到群聊设置,来到群机器人页面添加群机器人,设置群机器人昵称点击添加,机器人添加完成后出现的页面,请点击 Webhook 地址后的复制按钮;注意一般只有群主才有对应的权限哦。
<dependency>
<groupId>io.GitHub.swalikh</groupId>
<artifactId>wework-wehook-starter</artifactId>
<version>1.0.0</version>
</dependency>
spring:
message:
wechat-webhooks:
- https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxxxxxxx
- Https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxxxxxxx
@Autowired
private MessageService messageService;
1.发送普通文本消息
WeWorkWebhookMessage wessage = WeWorkWebhookMessage.buildText("hello");
messageService.send(weWorkWebhookMessage);
2.发送图片(本地或者网络图片均可发送)
// networkImage 和 localImage 均可,格式可支持jpg&png
String networkImageUrl = "https://xxxxx/images/20210918100245.png";
String localImageFilePath = "/home/image/cat.png";
WeWorkWebhookMessage imageMessage =
WeWorkWebhookMessage.buildImageMessage(networkImageUrl);
messageService.send(imageMessage);
3.发送图文卡片消息(本地或者网络图片均可发送)
// networkImage 和 localImage 均可,格式可支持jpg&png
String networkImageUrl = "https://xxxx/images/20210918100245.png";
Article article = new Article()
.setTitle("这是卡片的标题")
.setUrl("http://www.Google.com/这是点击的链接地址")
.setPicurl(networkImageUrl)
.setDescription("这是描述文字");
WeWorkWebhookMessage articleMessage =
WeWorkWebhookMessage.buildNewsMessage(article);
messageService.send(articleMessage);
4.发送markdown消息
MarkdownBuffer markdownBuffer = new MarkdownBuffer();
markdownBuffer.h2("H2").nextLine()
.h3("H3").nextLine()
.quote("quote").quoteEnd()
.green("greenText").nextLine()
.orange("orangeText").nextLine()
.gray("grayText").nextLine()
.code("single line code").nextLine()
.link("link title","line URL").nextLine();
WeWorkWebhookMessage markDownMessage =
WeWorkWebhookMessage.buildMarkDownMessage(markdownBuffer);
messageService.send(markDownMessage);
yml配置:
public void send(NotifyPlatfORM platform, String text) {
String serverUrl = WechatNotifyConst.WECHAT_WEH_HOOK + platform.getUrlKey();
MarkdownReq markdownReq = new MarkdownReq();
markdownReq.setMsgtype("markdown");
MarkdownReq.Markdown markdown = new MarkdownReq.Markdown();
markdown.setContent(text);
markdownReq.setMarkdown(markdown);
try {
HttpResponse response = HttpRequest.post(serverUrl).body(JSONUtil.tojsonStr(markdownReq)).execute();
if (Objects.nonNull(response)) {
log.info("DynamicTp notify, wechat send success, response: {}, request:{}",
response.body(), JSONUtil.toJsonStr(markdownReq));
}
} catch (Exception e) {
log.error("DynamicTp notify, wechat send failed...", e);
}
}
以上就是SpringBoot整合企微webhook机器人发送消息提醒的详细内容,更多关于springboot webhook发送消息的资料请关注编程网其它相关文章!
--结束END--
本文标题: springboot整合企微webhook机器人发送消息提醒
本文链接: https://www.lsjlt.com/news/175230.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
一口价域名售卖能注册吗?域名是网站的标识,简短且易于记忆,为在线用户提供了访问我们网站的简单路径。一口价是在域名交易中一种常见的模式,而这种通常是针对已经被注册的域名转售给其他人的一种方式。
一口价域名买卖的过程通常包括以下几个步骤:
1.寻找:买家需要在域名售卖平台上找到心仪的一口价域名。平台通常会为每个可售的域名提供详细的描述,包括价格、年龄、流
443px" 443px) https://www.west.cn/docs/wp-content/uploads/2024/04/SEO图片294.jpg https://www.west.cn/docs/wp-content/uploads/2024/04/SEO图片294-768x413.jpg 域名售卖 域名一口价售卖 游戏音频 赋值/切片 框架优势 评估指南 项目规模
0