钉钉机器人webhook的使用
1、群启动webhook机器人:右上角设置--智能助手---添加机器人---其他机器人
2、获取webhook地址

3、调用方式不一样,则访问方式就不一样

--------------------------------------------方式一:加签-----------------------------------------------
1、python加签名的调用方式
pip install requests
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | import requests import json import time import hmac import hashlib import base64 import urllib.parse def send_text(countent_text): timestamp = str ( round (time.time() * 1000 )) secret = 'SECc1495b626ab6ceb2415ee163ca3002cf2c77cbba82f6f3d55d9014c2ee58ed41' #签名id secret_enc = secret.encode( 'utf-8' ) string_to_sign = '{}\n{}' . format (timestamp, secret) string_to_sign_enc = string_to_sign.encode( 'utf-8' ) hmac_code = hmac.new(secret_enc, string_to_sign_enc, digestmod = hashlib.sha256).digest() sign = urllib.parse.quote_plus(base64.b64encode(hmac_code)) url = f "https://oapi.dingtalk.com/robot/send?access_token=8684ad760333e6fbb8ec8c0c12e2c00fcf7e58e58eb5d0152d9cebb06dee×tamp={timestamp}&sign={sign}" headers = { 'Content-Type' : 'application/json;charset=utf-8' } data = { "msgtype" : "text" , "at" : { "atMobiles" : [ "18381001111" ], #群中@的人员 "isAtAll" : False }, "text" : { "content" : countent_text}, "msgtype" : "text" } print (json.dumps(data)) print (countent_text) requests.post(url, headers = headers, data = json.dumps(data)) dx = f "-----------------------------sdfsdfsdf--------------------------------" send_text(dx) |
--------------------------------------------方式二:自定义关键词---------------------------------------------
1、自定义关键词test
1 2 3 4 5 6 7 8 9 10 11 12 | import requests import json def send_text(countent_text): url = f "https://oapi.dingtalk.com/robot/send?access_token=8684ad760333e6fbb8ec8c0c12e2c00fcf7e58e58eb5d0152d906de" headers = { 'Content-Type' : 'application/json;charset=utf-8' } data = { "msgtype" : "text" , "text" : { "content" : countent_text}} print (json.dumps(data)) print (countent_text) requests.post(url, headers = headers, data = json.dumps(data)) dx = f "test----------------------------sdfsdfsdf--------------------------------" send_text(dx) |
2、linux下直接curl调用
1 | curl - H "Content-Type: application/json" - X POST - d '{"msgtype": "text", "text": {"content": "test1"}}' "https://oapi.dingtalk.com/robot/send?access_token=8684ad760333e6fbb8ec8c0c12e2c00fcf7e58e58eb5d0152d9cebb06dee" |
做一个决定,并不难,难的是付诸行动,并且坚持到底。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
2020-07-27 使用ruby 进行redis集群安装
2020-07-27 jenkins重新初始化admin