钉钉 添加机器人 往群里发消息的 实现方法
在的钉钉创建一个群
群设置-智能群助手-添加自定义机器人
添加后获取 webhook 和 自定义关键词(发送请求要带这个关键字)

然后按你要的展示方式 ,往 webhook 发送请求 ,即可在群里 展示
# 接口文档 https://ding-doc.dingtalk.com/doc#/serverapi2/qf2nxq/404d04c3

url ="https://oapi.dingtalk.com/robot/send?access_token=24655395da2e0a169f71998378f2dee03c14c46eded0b1981bd13267cddc9757"
data ={"at": {"atMobiles": ["1599472717811"],"isAtAll": True},"text": {"content": "我就是我, @180xxxxxx 是不一样的烟火"},"msgtype": "text"}
headers = {"Content-Type": "application/json"}
r = requests.post(url, json=data, headers=headers)
print(r.json())
  data= \
        {
            "at": {"isAtAll": True},
            "msgtype": "markdown",
            "markdown": {
                "title": "警告提示",
                "text": f"{msg}"
                 "\n\n[点击查看接口详情]" + "(" + "https://platform-test.codemao.cn/api/checkrequest/" + ")"
            }
        }
    headers = {"Content-Type": "application/json"}
    r = requests.post(url, json=data, headers=headers)
  mark_down_text = f'#### {envir}环境测CRP执行接口告知\n> {pro_name}测试用例执行完成,统计结果:失败{f_count}条,共运行{(s_count + f_count)}条用例,达到了告警阈值\n> ###### {cur_time}提示,详情点击查看 [测试报告]({url}) \n'
                  
红色消息markdown写法
data = \
        {
            "msgtype": "markdown",
            "markdown": {
                "title": "常规巡检提示",
                # "text": str(msg).replace("[","").replace("]","").replace("'","").replace(",","")
                "text": "<font color=#FF0000>这里是红色文字</font>"+
                        "\n\n[点击查看接口详情]" + "(" + "https://test-ssss" + ")"+
                        "<font color ='red'> 这里设置文本颜色为红色。上线 </font>"
            } }
 
                    
                
 
 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号