【python】钉钉告警接口

#!/usr/bin/env python
# -- coding: utf-8 --
import json,urllib2,sys

@property
def dingding(tokenid,message):
url = “https://oapi.dingtalk.com/robot/send?access_token=” + tokenid
header = {
“Content-Type”: “application/json”,
“charset”: “utf-8”
}
data = {
“msgtype”: “text”,
“text”: {
“content”: message
}
}
sendData = json.dumps(data)
request = urllib2.Request(url,data = sendData,headers = header)
urlopen = urllib2.urlopen(request)
return urlopen.read()

猜你喜欢

转载自blog.csdn.net/shimming/article/details/82979953