我们在企业内部经常会建立一个新的群组进行一个项目的消息收发,但是钉钉除使用管理后台操作外没有办法批量导入名单进行快速建群,一个一个拉人非常痛苦(30人以上群)手发麻。
基于Flask开发了钉钉建群小助手,需要用到requests这个库进行钉钉接口的调用。
基本原理,钉钉后台创建一个企业内部应用(H5快捷方式)获取App密钥以及打开此APP的权限(在管理后台操作),获取企业凭证后通过用户手机号获取用户id,最后请求建群接口批量将成员拉入建群。
static中的mb.xlsx表格文件存放姓名手机号,用于匹配人名查找到该用户手机号方便获取钉钉用户id 。
templates中存放html页面
leadin.html(不会前端,写的非常烂)
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width,
user-scalable=no,
initial-scale=1.0,
maximum-scale=1.0,
minimum-scale=1.0">
<title>钉钉建群助手</title>
<link rel="icon" href="../static/favicon.ico">
<style>
* {
margin: 0;
padding: 0;
}
a {
text-decoration: none;
color: cornflowerblue;
}
.shang {
width: 100%;
height: 150px;
position: absolute;
top: 0;
box-shadow: 0 2px 10px #888888;
}
.zhong {
overflow: auto;
position: absolute;
top: 150px;
bottom: 0;
width: 100%;
}
.tl {
margin-top: 20px;
margin-bottom: 35px;
text-align: center;
font-size: 30px;
font-weight: bold;
}
input {
outline: none;
border: 1px solid #aaa;
width: 140px;
height: 26px;
border-radius: 10px;
margin-left: 10px;
margin-right: 10px;
}
.sub {
width: 80px;
line-height: 26px;
cursor: pointer;
background-color: indianred;
color: white;
font-weight: bold;
transition: 650ms;
}
.sub:hover {
background-color: cornflowerblue;
}
.tlmsg {
text-align: center;
color: indianred;
font-weight: bold;
font-size: 20px;
margin