当前位置:网站首页>DingTalk Enterprise Internal-H5 Micro Application Development
DingTalk Enterprise Internal-H5 Micro Application Development
2022-07-31 06:24:00 【Forevermoremo】
Foreword
The company needs to use DingTalk-related API to complete the company's internal reimbursement platform.
Project construction
- Create H5 Microapp
Log in to DingTalk Open Platform (https://open-dev.dingtalk.com/#/index), enter "Application Development" -> Internal Development of H5 Micro-Apps -> Create Application, and fill in basic information and configuration development information

Note: Application home page link: vscode needs to install the Liver Server plug-in, open the home page in this way, replace the IP address of the obtained address with the local IP address, and get the application home page link.
2. JSAPI authentication API development
(1) Development of JSAPI authentication server API:
① Obtain the call interface certificate AccessToken through appKey and appSecret (https://oapi.dingtalk.com/gettoken? appkey=appKey&appsecret=appSecret)
②Get a temporary ticket Ticket for JSAPI through AccessToken(https://oapi.dingtalk.com/get_jsapi_ticket?access_token=ACCESS_TOKEN)
I will not write the details of the backend. If you are interested, you can take a look at Dingding Server API Development Document
(2) Development of JSAPI authentication front-end API:
The front end obtains the JSAPI authentication configuration information of the server by sending a request.
if (!localStorage.getItem('sessionId')) {console.log("Authentication started");//App homepage linkvar datas = { "url": "http://192.168.0.66:5500/html/index.html" };apiRequest('post', 'ding_talk/config', datas, function (data) {_config = data.row;dd.config({agentId: _config.agentId, // required, micro application IDcorpId: _config.corpId,//required, enterprise IDtimeStamp: _config.timeStamp, // Required, the timestamp for generating the signaturenonceStr: _config.nonceStr, // Required, generate a random string for signaturesignature: _config.signature, // required, signaturetype: 0, //Optional.0 means the jsapi of the micro application, 1 means the jsapi of the service window; if not filled, the default is 0.This parameter is supported since version 0.8.3 of dingtalk.jsjsApiList: []});dd.ready(function () {console.log('Authentication successful');//Log in});dd.error(function (err) {window.localStorage.setItem("sessionId", '');console.log('dd error: ' + JSON.stringify(err));});}, function (res) {dd.error(function (err) {console.log('dd error: ' + JSON.stringify(err));});console.log(res);});}(3) H5 micro-app free login (users automatically log in to the app)
After the backend gets the login authorization code, it obtains the user information through the server API (/user/getuserinfo) and returns it.
dd.runtime.permission.requestAuthCode({corpId: _config.corpId, // enterprise idonSuccess: function (info) {code = info.code; // User identity information can be obtained through the login-free authorization code//Log inapiRequest('post', 'ding_talk/login', { "code": code }, function (data) {window.localStorage.setItem("sessionId", data.row.sessionId);window.localStorage.setItem("userId", data.row.userId);}, function (res) {console.log(res);})},onFail: function (res) {window.localStorage.setItem("sessionId", '');}});For details on the front-end, see Front-end API Development Documentation
边栏推荐
猜你喜欢

CAS:474922-22-0 Maleimide-PEG-DSPE Phospholipid-Polyethylene Glycol-Maleimide Brief Description

Fluorescein-PEG-DSPE 磷脂-聚乙二醇-荧光素荧光磷脂PEG衍生物

MW:3400 4-Arm PEG-DSPE 四臂-聚乙二醇-磷脂一种饱和的18碳磷脂

Remote file xxx is mapped to the local path xxx and can‘t be found. You can continue debugging....

CAS:474922-22-0 Maleimide-PEG-DSPE 磷脂-聚乙二醇-马来酰亚胺简述

np.fliplr与np.flipud

Learn how to get a database connection with JDBC

变分自编码器VAE实现MNIST数据集生成by Pytorch

2022 SQL big factory high-frequency practical interview questions (detailed analysis)

四种常见的POST提交数据方式
随机推荐
多元线性回归方程原理及其推导
VS2017连接MYSQL
qt:cannot open C:\Users\某某某\AppData\Local\Temp\main.obj.15576.16.jom for write
Podspec verification dependency error problem pod lib lint , need to specify the source
四种常见的POST提交数据方式
VS通过ODBC连接MYSQL(二)
Cholesterol-PEG-Amine CLS-PEG-NH2 Cholesterol-Polyethylene Glycol-Amino Research Use
Fluorescein-PEG-DSPE 磷脂-聚乙二醇-荧光素荧光磷脂PEG衍生物
DSPE-PEG-Thiol DSPE-PEG-SH 磷脂-聚乙二醇-巯基脂质体制备用
Pytorch每日一练——预测泰坦尼克号船上的生存乘客
Tensorflow——演示
2022年SQL大厂高频实战面试题(详细解析)
计算图像数据集均值和方差
CAS:474922-22-0 Maleimide-PEG-DSPE 磷脂-聚乙二醇-马来酰亚胺简述
VS通过ODBC连接MYSQL(一)
DSPE-PEG-COOH CAS:1403744-37-5 磷脂-聚乙二醇-羧基脂质PEG共轭物
活体检测CDCN学习笔记
MySQL 主从切换步骤
使用 OpenCV 提取图像的 HOG、SURF 及 LBP 特征 (含代码)
MW: 3400 4-Arm PEG-DSPE four-arm-polyethylene glycol-phospholipid a saturated 18-carbon phospholipid