Skip to content

zf-z/FeishuAutoTools

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FeishuAutoTools

一款用于飞书的流程自动化工具😊

Introduction

自己的业务主要是为了汇总共享文档里的日报,在此需求上实现了几个接口,如有需求者可以自取。

生成的日报demo:

project tree:

FeishuAutoTools
│  crontab.cfg    // crontab配置文件
│  script.sh      // 运行业务代码的脚本
├─biz                           // 自己的业务代码
│  │  conf.py
│  │  download_sheet_data.py    // 下载飞书云文档的sheet内容到本地
│  │  log_conf.py
│  │  refresh_token.py         // 刷新user_access_token和refresh_token
│  │  send_email.py            // 发送邮件的模块
│  │  work_summary.py          // 汇总日报
│  └─ __init__.py
├─daily_reports                // 保存日报的目录
├─feishu                       // 飞书相关接口
│  │  authen_api.py            // 身份验证相关接口
│  │  conf.py
│  │  http_utils.py            // https utils
│  │  sheets_api.py            // 操作sheet相关接口
│  │  token.txt                // 保存user_access_token和refresh_token
│  └─ __init__.py
├─log          // 日志目录
└─template     // 业务用到的.xlsx和.docx

How to Use API

1. 创建应用和获得凭证

  1. 创建企业自建应用: 参考文档
  2. 获取授权凭证:参考文档

2. 进行身份验证

  1. 身份验证开发指南:参考文档
  2. 第一次使用时,需要构造https://open.feishu.cn/open-apis/authen/v1/index?redirect_uri={REDIRECT_URI}&app_id={APPID}格式的链接,在浏览器发送请求,然后完成扫码登录。登录成功后会生成登录预授权码 code,并作为参数重定向到重定向URL。 用返回的code修改./feishu/authen_api.pyauthen_code_的值,然后运行authen_api.py,将返回结果中的access_tokenrefresh_token复制出来粘贴到./feishu/token.txt
  3. 由于access_token不到两小时就会过期,可以配置一个定时任务保持刷新 --> 代码见./biz/refresh_token.py

3. 调用相关API

  1. 调用./feishu/authen_api.py./feishu/sheets_api.py中的接口即可。注意:调用需要access_token的API前,最好先刷新一下tokens避免过期
  2. 可以参考官网文档实现更多API:

Reference

About

FeishuAutoTools

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 98.9%
  • Shell 1.1%