当前位置:网站首页>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
边栏推荐
猜你喜欢

Cholesterol-PEG-Amine CLS-PEG-NH2 Cholesterol-Polyethylene Glycol-Amino Research Use

Cholesterol-PEG-Azide CLS-PEG-N3 Cholesterol-PEG-Azide MW:3400

DSPE-PEG-Biotin, CAS: 385437-57-0, phospholipid-polyethylene glycol-biotin prolongs circulating half-life

科学研究用磷脂-聚乙二醇-活性酯 DSPE-PEG-NHS CAS:1445723-73-8

Attention based ASR(LAS)

活体检测FaceBagNet阅读笔记

Pytorch实现ResNet

Navicat从本地文件中导入sql文件

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

DSPE-PEG-Azide DSPE-PED-N3 Phospholipid-Polyethylene Glycol-Azide Lipid PFG
随机推荐
pytorch模型微调finetuning训练image_dog(kaggle)
RuntimeError: CUDA error: no kernel image is available for execution on the device问题记录
opencv之图像二值化处理
浏览器中的画中画(Picture-in-Picture)API
Pytorch常用函数
Navicat从本地文件中导入sql文件
ERROR Error: No module factory availabl at Object.PROJECT_CONFIG_JSON_NOT_VALID_OR_NOT_EXIST ‘Error
学习JDBC之获取数据库连接的方式
cocos2d-x implements cross-platform directory traversal
如何修改数据库密码
化学试剂磷脂-聚乙二醇-氨基,DSPE-PEG-amine,CAS:474922-26-4
qt:cannot open C:\Users\某某某\AppData\Local\Temp\main.obj.15576.16.jom for write
IDEA控制台不能输入信息的解决方法
Cholesterol-PEG-Azide CLS-PEG-N3 胆固醇-聚乙二醇-叠氮 MW:3400
ROS 之订阅多个topic时间同步问题
TransactionTemplate transaction programmatic way
活体检测FaceBagNet阅读笔记
wangeditor富文本编辑器上传图片以及跨域问题解决
词向量——demo
Learn how to get a database connection with JDBC