Re钉钉微应用如何打开本地app (Android)
经测试,免登认证已成功,执行 dd.device.launcher.checkInstalledApps 失败报not authorized
-------------------------
回 2楼识器的帖子
你好,我参考了例子,我用调试工具获取的signature 已自己生成的对比,是一致的,但是就是在执行 dd.device.launcher.checkInstalledApps报未授权not authorized errCode:7
-------------------------
回 4楼识器的帖子
按你所说,我把dd 去掉了,还是不可以
-------------------------
Re钉钉微应用如何打开本地app (Android)
为什么我先访问action 签名后回到页面会认证说权限校验失败
@RequestMapping(value="/dd/openCoreMail.action")
public String openCoreMail(HttpServletRequest request,ModelMap model){
String url=request.getRequestURL().toString();
String querString=request.getQueryString();
if(!StringUtils.isEmpty(querString)&&(!querString.equals("null"))){
try {
querString=URLEncoder.encode(querString, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}else{
querString=null;
}
String result=AuthHelper.getConfig(url,querString);
JSONObject jobj=JSONObject.fromObject(result);
System.out.println(result);
Map map =new HashMap();
map.put("SIGNATURE", jobj.getString("signature"));
map.put("NONCESTR", jobj.getString("nonceStr"));
map.put("TIMESTAMP", jobj.getString("timeStamp"));
map.put("CORPID", Env.CORP_ID);
map.put("APPID", null);
model.addAttribute("ROOT",map);
return "dingTalk/openCoreMail";
}
下面是页面
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://com/hbglobal/taglib/myplug" prefix="Ding"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>openCoreMail</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
</head>
<body>
<script type="text/javascript"
src="${pageContext.request.contextPath}/dwr/engine.js"></script>
<script type="text/javascript"
src="${pageContext.request.contextPath}/dwr/util.js"></script>
<script type="text/javascript"
src="${pageContext.request.contextPath}/dwr/interface/MobileMeetingAction.js"></script>
<script src='${pageContext.request.contextPath}/js/jquery-1.11.3.js'></script>
<script
src='${pageContext.request.contextPath}/js/jquery-migrate-1.2.1.min.js'></script>
<script type="text/javascript"
src="${pageContext.request.contextPath}/js/dingtalk.js"></script>
<script type="text/javascript">
dd.config({
agentId : '${ROOT.APPID}',
corpId : '${ROOT.CORPID}',
timeStamp : '${ROOT.TIMESTAMP}',
nonceStr : '${ROOT.NONCESTR}',
signature : '${ROOT.SIGNATURE}',
jsApiList : [ 'device.notification.alert',
'device.notification.confirm',
'runtime.permission.requestAuthCode',
'runtime.permission.requestJsApis',
'device.launcher.launchApp',
'device.launcher.checkInstalledApps'
]
});
dd.error(function(err) {
alert("aa" + JSON.stringify(err));
});
function aa(data) {
alert("call:" + data);
}
function openMail(data) {
dd.device.launcher.launchApp({
app : 'cn.mailtech.app', //iOS:应用scheme;Android:应用包名
onSuccess : function(data) {
//alert(data);
},
onFail : function(err) {
alert("app:" + JSON.stringify(err));
}
});
}
dd.ready(function(bridge) {
dd.runtime.permission.requestAuthCode({
corpId : '${ROOT.CORPID}',
onSuccess : function(info) {
openMail(info);
//MobileMeetingAction.getDDUserByCode(info.code, openMail);
},
onFail : function(err) {
alert("hha" + JSON.stringify(err));
}
});
});
</script>
</body>
</html>
但是如果我直接不通过action 直接不把页面放在WEB_INF如下却可以,有什么解决办法没
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page import="com.hbglobal.ding.auth.AuthHelper,
org.apache.commons.lang.StringUtils,java.net.URLEncoder,
java.io.UnsupportedEncodingException,com.hbglobal.listener.DingDingListener,
net.sf.json.JSONObject,com.hbglobal.ding.po.Env" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>openCoreMail</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
</head>
<body>
<%
String url=request.getRequestURL().toString();
String querString=request.getQueryString();
System.out.println(url+":"+querString);
if(!StringUtils.isEmpty(querString)&&(!querString.equals("null"))){
try {
querString=URLEncoder.encode(querString, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}else{
querString=null;
}
String result=AuthHelper.getConfig(url,querString);
JSONObject jobj=JSONObject.fromObject(result);
System.out.println(result);
String SIGNATURE= jobj.getString("signature");
String NONCESTR=jobj.getString("nonceStr");
String TIMESTAMP= jobj.getString("timeStamp");
String CORPID= Env.CORP_ID;
%>
<a href="javaScript:openMail()">启动范文</a>
<script type="text/javascript"
src="${pageContext.request.contextPath}/js/dingtalk.js"></script>
<script type="text/javascript"
src="${pageContext.request.contextPath}/dwr/engine.js"></script>
<script type="text/javascript"
src="${pageContext.request.contextPath}/dwr/util.js"></script>
<script type="text/javascript"
src="${pageContext.request.contextPath}/dwr/interface/MobileMeetingAction.js"></script>
<script src='${pageContext.request.contextPath}/js/jquery-1.11.3.js'></script>
<script
src='${pageContext.request.contextPath}/js/jquery-migrate-1.2.1.min.js'></script>
<script type="text/javascript">
$(function(){
dd.config({
agentId : '9868138',
corpId : '<%=CORPID%>',
timeStamp : '<%=TIMESTAMP%>',
nonceStr : '<%=NONCESTR%>',
signature : '<%=SIGNATURE%>',
jsApiList : [ 'device.notification.alert',
'device.notification.confirm',
'runtime.permission.requestAuthCode',
'runtime.permission.requestJsApis',
'device.launcher.launchApp',
'device.launcher.checkInstalledApps'
]
});
});
function aa(data) {
alert("call:" + data);
}
function openMail(data) {
dd.device.launcher.launchApp({
apps :'cn.mailtech.app' , //iOS:应用scheme;Android:应用包名
onSuccess : function(data) {
alert(data);
},
onFail : function(err) {
alert("app:" + JSON.stringify(err));
}
});
}
dd.ready(function() {
dd.runtime.permission.requestAuthCode({
corpId : '<%=CORPID%>',
onSuccess : function(info) {
//MobileMeetingAction.getDDUserByCode(info.code, openMail);
},
onFail : function(err) {
alert("hha" + JSON.stringify(err));
}
});
});
dd.error(function(err) {
alert("aa" + JSON.stringify(err));
});
</script>
</body>
</html>