赞
踩
首先建群,建机器人,不多说,自行操作,获取webhook,通过webhook发送信息,原api地址: https://open.feishu.cn/document/ukTMukTMukTM/ucTM5YjL3ETO24yNxkjN
1、发送普通消息,代码如下
import requests import json def get_data(): data = { "msg_type": "text", "content": { "text": "你好" } } return json.dumps(data,ensure_ascii=True).encode("utf-8") def req(data): #webhook url = "https://open.feishu.cn/open-apis/bot/v2/hook/111-22-33-44" header = { "Content-type": "application/json", "charset":"utf-8" } requests.post(url,data=data,headers=header) if __name__ == '__main__': req(get_data())
效果图
2、发送富文本
import requests import json def get_data(): data = { "msg_type": "post", "content": { "post": { "zh_cn": { "title": "项目更新通知", "content": [ [{ "tag": "text", "text": "项目有更新: " }, { "tag": "a", "text": "请查看", "href": "https://www.baidu.com/" }, { "tag": "at", "user_id": "123456" } ] ] } } } } return json.dumps(data,ensure_ascii=True).encode("utf-8") def req(data): url = "https://open.feishu.cn/open-apis/bot/v2/hook/11-11-22-33" header = { "Content-type": "application/json", "charset":"utf-8" } requests.post(url,data=data,headers=header) if __name__ == '__main__': req(get_data())
效果图
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。