钉钉api

This commit is contained in:
z66
2025-10-30 17:24:28 +08:00
parent c5a5a0a99c
commit 4154eb452f
14 changed files with 1192 additions and 1323 deletions
+41
View File
@@ -0,0 +1,41 @@
import requests
from typing import Optional
class DingAPI():
def __init__(self):
self.token = None
self.url = ''
def get_token(self) -> Optional:
"""
获取Access Token
return: token(str)
"""
url = 'https://api.dingtalk.com/v1.0/oauth2/dinga88e3d35525b86ca/token'
payload = {
"client_id": "dingn3de1pyuwkymohhe",
"client_secret": "qv__egWJnLVXh14_R1rfD_vBi7M8Gzhnk94EJN6puMzsqqpBCP8U7Ow-zA7SV8Rx",
"grant_type": "client_credentials"
}
response = requests.post(url, json=payload)
token = response.json().get('access_token')
return token
def send_message(self, message):
data = {
"msgtype": "text",
"text": {
"content": message
}
}
headers = {
'Content-Type': 'application/json'
}
response = requests.post(self.url, json=data, headers=headers)
return response.status_code