本文介绍如何使用Python3程序通过钉钉群机器人发送消息到群中。
钉钉群机器人有三种安全设置,本文使用加签方式,理论上兼容其他两种。
#!/usr/bin/python3
# -*- coding: utf-8 -*-
#钉钉群机器人 Python3版
import time,datetime
import hmac,hashlib,base64
import urllib.parse
import requests
import json
class DINGDING:
apiurl = "https://oapi.dingtalk.com"
def __init__(self, accesstoken, secret):
self.access_token = accesstoken
self.secret = secret
# 发送消息,群机器人
def send_message_group(self, type, data):
if type not in ["text", "link", "markdown", "actionCard", "feedCard"] or not data:
raise Exception("ERROR type %s or empty data"%(type))
return
msg = {
'msgtype' : type,
}
if type == "text":
msg[type] = {
'content' : data}
elif type == "link":
msg[type] = data
elif type == "markdown":
msg[type] = data
elif type == "actionCard":
msg[

这篇博客详细介绍了如何利用Python3来与钉钉群机器人交互,发送消息到群聊中。文中提到,针对钉钉群机器人的三种安全设置,此方法专注于加签方式,并且可能兼容其他安全模式。
最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



