import requests import json def getDingMes(): baseUrl = " your hook address。" # please set charset= utf-8 HEADERS = { "Content-Type": "application/json ;charset=utf-8 " } # 这里的message是你想要推送的文字消息 message = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" stringBody ={ "msgtype": "text", "text": {"content": message}, "at": { "atMobiles": ["1825718XXXX"], "isAtAll": True #@所有人 时为true,上面的atMobiles就失效了 } } MessageBody = json.dumps(stringBody) result = requests.post(url=baseUrl, data=MessageBody, headers=HEADERS) print(result.text) if __name__ == '__main__': getDingMes()
钉钉群自定义机器人群发文本代码
来源:https://www.cnblogs.com/chezxj/p/12585475.html