1.安装包
pip install alibabacloud_dingtalk
2.创建企业内部应用及机器人
1.创建成功后, 得到应用及机器人的相关应用凭证, 用于后续接口取数.
2.首先获取应用的access_token
对于无法获取dingtalk.api的bug,
解决方法为: 在开放平台https://open.dingtalk.com/document/orgapp-server/download-the-server-side-sdk 下载旧版 python3 SDK (https://open-dev.dingtalk.com/download/openSDK/python3?spm=ding_open_doc.document.0.0.28ff2b49JNLWPn) ,解压后将 dingtalk文件夹 传到python 库的目录下,import dingtalk.api 不再报错。
# -*- coding: utf-8 -*-
import dingtalk.api
req=dingtalk.api.OapiGettokenRequest("https://oapi.dingtalk.com/gettoken")
req.appkey="xxxxx"
req.appsecret="xxxxx"
try:
resp= req.getResponse('access_token')
print(resp)
print(resp['access_token'])
except Exception as e:
print(e)
标签:内部,dingtalk,记录,resp,req,access,api,应用,open
From: https://www.cnblogs.com/feng-hao/p/17029503.html