zhangauckland 2020-10-26 09:36 采纳率: 0%
浏览 149

如何用Python获取企业微信日程?

各位前辈,我尝试获取企业微信中的日程,代码如下:
import requests
import json

def get_token(corpid,apisecret):
#获取token时,携带企业id和secret(注册企业号时,后台可查)
url = 'https://qyapi.weixin.qq.com/cgi-bin/gettoken'
values = {
'corpid': corpid,
'corpsecret': apisecret,
}
req = requests.get(url, params=values)
data = json.loads(req.text)
return data["access_token"]

def get_schedule(corpid,apisecret):
token = get_token(corpid,apisecret)
url = 'https://qyapi.weixin.qq.com/cgi-bin/oa/schedule/get?access_token=%s' % token
r = requests.get(url)
print("Status code:", r.status_code)
# 将API响应存储在一个变量中
response_dict = r.json()
print("keys of response_dict:", response_dict.keys())
print("errcode: ", response_dict['errcode'])
print("errmsg: ", response_dict['errmsg'])
print("schedule_list: ", response_dict['schedule_list'])
return response_dict

运行结果显示:
Status code: 200
keys of response_dict: dict_keys(['errcode', 'errmsg', 'schedule_list'])
errcode: 90462
errmsg: calendar id list is empty, hint: [1603675806_59_4b56b3aa599fa47849ab5590c854a4b2], from ip: 218.89.243.12, more info at https://open.work.weixin.qq.com/devtool/query?e=90462
schedule_list: []

烦请各位大侠指教,为何会出现calendar id list is empty?不知是何处出了出了问题?谢谢!

  • 写回答

1条回答 默认 最新

  • lshen01 2023-03-16 18:06
    关注

    参考GPT和自己的思路:

    根据API文档,企业微信中的日程需要指定具体的日历ID,而在你的代码中并没有指定日历ID,所以出现了"calendar id list is empty"的错误。你需要通过企业微信后台或者API接口获取到需要读取的日历ID,并把它作为参数传给接口。在代码中,可以在url的末尾添加一个参数:calendar_id={日历ID}。另外,获取日历的时间范围也需要指定,可以添加start_time和end_time两个参数来限制时间范围。

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器