注册开发者账号

https://developers.dingtalk.com/

企业自主(内部)开发小程序

工具准备:

idea、maven、java、git、钉钉小程序开发工具(可编写代码、调试、上传到钉钉等)

流程:

  1. 创建应用,这步会产生AppKey与AppSecret,然后是权限、服务器白名单等配置

image.png

  1. 开发和部署后端服务,自己的功能,配置好 AppKey 与 AppSecret,配置好后端服务地址(没有公网地址,钉钉允许使用内网穿透来调试);
  2. 开发小程序前端,上传与发布

遇到的问题

配置问题导致的错误:

前端界面错误:
image.png
后端日志:

  1. 2021-08-03 13:53:04.455 ERROR 5732 --- [nio-8080-exec-9] topsdk : 2021-08-03 13:53:04.454^_^_dingtalk_^_^dingtalk.oapi.v2.user.getuserinfo^_^192.168.0.110^_^Windows 10^_^255^_^https://oapi.dingtalk.com/topapi/v2/user/getuserinfo^_^access_token=53fc8f2466bf3ea79f23ff136b615465&code=d114bcebaec232e381090f9703c8e288^_^{"errcode":88,"sub_code":"60020","sub_msg":"访问ip不在白名单之中,请参考FAQ:https://developers.dingtalk.com/document/app/app-faq/title-9eg-fgn-1ml,request ip=218.89.238.54 appKey(dingz1sqdqum8g1qzagf)","errmsg":"ding talk error[subcode=60020,submsg=访问ip不在白名单之中,请参考FAQ:https://developers.dingtalk.com/document/app/app-faq/title-9eg-fgn-1ml,request ip=218.89.238.54 appKey(dingz1sqdqum8g1qzagf)]","request_id":"q5msmztgenro"}
  2. 2021-08-03 11:54:48.201 ERROR 5732 --- [nio-8080-exec-5] topsdk : 2021-08-03 11:54:48.200^_^_dingtalk_^_^dingtalk.oapi.v2.user.get^_^192.168.0.110^_^Windows 10^_^255^_^https://oapi.dingtalk.com/topapi/v2/user/get^_^access_token=53fc8f2466bf3ea79f23ff136b615465&userid=276205010335140370&language=zh_CN^_^{"errcode":88,"sub_code":"60011","sub_msg":"没有调用该接口的权限,接口权限申请参考:https://developers.dingtalk.com/document/app/add-api-permission","errmsg":"ding talk error[subcode=60011,submsg=没有调用该接口的权限,接口权限申请参考:https://developers.dingtalk.com/document/app/add-api-permission]","request_id":"4zc132q35zt8"}

解决办法:
授权;
服务出口IP,类似于白名单(本地,利用ip,查一下本地路由ip,配置上去)

注意

删除小程序,无法恢复,即使重建,名称一样的情况下,一时半会也不出来(手机钉钉界面,我的是第二天出来的);

企业自主(企业内部)开发 H5微应用

1. 创建应用

取好名称、设置好服务出口IP、应用首页地址、权限

2. 开发 H5 应用

需要用到:
app_key:已创建应用的AppKey。
app_secret:已创建应用的AppSecret。
agent_id:已创建应用的AgentId。
corp_id:应用所属的CorpId。CorpId可以在开发者后台首页获取。

3. 发布H5应用

发布应用,选择使用人员

H5 遇到的问题

1. 官方demo无法 mvn install :

报错:
Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.6:yarn (yarn install) on project frontend: Failed to run task: ‘yarn install’ failed. org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1) -> [Help 1]
使用 mvn install -e 发现存在乱码(目录路径乱码),果断将目录变为英文的。

2. 页面无法访问,网络错误,或者提示没有返回

前面测试官网小程序,和本次使用的 H5 微应用使用的同一个内网穿透(代理的地址一样,且端口一样),怀疑二则冲突,修改内网穿透。

3. 中间遇到无权限

报错:
2021-08-04 14:09:21.913 ERROR 19848 —- [nio-9091-exec-6] topsdk : 2021-08-04 14:09:21.912^^_dingtalk^^dingtalk.oapi.user.get^^192.168.0.110^^Windows 10^^247^^[https://oapi.dingtalk.com/user/get^^accesstoken=f43cbf4e12f931e68a917616ca7cf71e&userid=276205010335140370^^{“errcode”:60011,”errmsg”:”](https://oapi.dingtalk.com/user/get^_^access_token=f43cbf4e12f931e68a917616ca7cf71e&userid=276205010335140370^_^{"errcode":60011,"errmsg":")没有调用该接口的权限,接口权限申请参考:[https://developers.dingtalk.com/document/app/add-api-permission"}](https://developers.dingtalk.com/document/app/add-api-permission"})

对应修改权限即可。

4. 可接入监控

按照要求,在对应页面加入监控代码。

企业内部开发机器人

使用demo没能搞通。。。竟无语凝噎。。。