Re遇到errorCode7 requestJsApisnot invoked,所有接口调用不了
//根据客户端请求的URL生成dd.config需要的JSON配置信息
function get_config($url)
{
$corpId =
CORPID;
$agentId =
AGENTID;
$nonceStr =
'aaaaaaa';
$timeStamp = time();
$corpAccessToken = get_token();
if (!$corpAccessToken) {
$config =
false;
}
else {
$ticket = get_ticket($corpAccessToken);
if (!$ticket) {
$config =
false;
}
else {
$signature = sign($ticket, $nonceStr, $timeStamp, $url);
$config =
array(
"url"=>$url,
"agentId" => $agentId,
"corpId" => $corpId,
"timeStamp" => $timeStamp,
"nonceStr" => $nonceStr,
"signature" => $signature
);
}
}
return json_encode($config,
JSON_UNESCAPED_SLASHES);
}
-------------------------
回 1楼人在囧途的帖子
token,ticket都能成功取得,返回的config json也正确,传入dd.config后,就是调用不了接口。
-------------------------
Re回 2楼人在囧途的帖子
{
"agentId":
"28604636",
"corpId":
"dinge048ce76f5dc0000",
"timeStamp":
146580000,
"nonceStr":
"aaaaaaa",
"signature":
"88c291f8ffa5f3bb5d66fd1a7f4ce16dd37e8b27",
"jsApiList":[
"runtime.info",
"device.notification.alert",
"device.notification.confirm",
"device.base.getUUID",
"device.geolocation.get",
"device.base.getInterface",
"device.nfc.nfcRead",
"device.launcher.checkInstalledApps",
"biz.util.uploadImage"]
}
//这里返回的config
-------------------------
Re遇到errorCode7 requestJsApisnot invoked,所有接口调用不了
var jsApiList =
[
'runtime.info',
'device.notification.alert',
'device.notification.confirm',
'device.base.getUUID',
'device.geolocation.get',
'device.base.getInterface',
'device.nfc.nfcRead',
'device.launcher.checkInstalledApps',
'biz.util.uploadImage'
];
$.
ajax
({
type:
'GET',
url:
'get_config.php',
data: {
url:
this.location.
href},
dataType:
'json',
success:
function
(
res
) {
if
(!
JSON.
stringify
(
res
)) {
alert
(
'config fail : ' +
JSON.
stringify
(
res
));
}
else {
res.
jsApiList = jsApiList;
dd.
config
(
res
); //这里调用dd.config()
alert
(
'config ok : '+
JSON.
stringify
(
res
));
}
},
error:
function
(
xhr,
type
) {
alert
(
'get config ajax error!'
)
}
}
);
//这是H5页面上通过ajax从服务器获取config配置信息。
-------------------------
回 4楼摸摸哒、的帖子
触发了。
-------------------------
回 4楼摸摸哒、的帖子
其实,你可以测试一下,就算不调用dd.config(),也可以触发dd.ready()
-------------------------
Re遇到errorCode7 requestJsApisnot invoked,所有接口调用不了
<
script
>
//alert(dd.version); //弹出显示 2.10.0
var jsApiList =
[
'runtime.info',
'device.notification.alert',
'device.notification.confirm',
'device.base.getUUID',
'device.geolocation.get',
'device.base.getInterface',
'device.nfc.nfcRead',
'device.launcher.checkInstalledApps',
'biz.util.uploadImage'
];
$.
ajax
({
type:
'GET',
url:
'get_config.php',
data: {
url:
this.location.
href},
dataType:
'json',
success:
function
(
res
) {
if
(!
JSON.
stringify
(
res
)) {
alert
(
'config fail : ' +
JSON.
stringify
(
res
));
}
else {
res.
jsApiList = jsApiList;
dd.
config
(
res
);
alert
(
'config ok : ' +
JSON.
stringify
(
res
));
}
},
error:
function
(
xhr,
type
) {
alert
(
'get config ajax error!'
)
}
}
);
dd.
error
(
function
(
error
) {
alert
(
'env error'
);
}
);
dd.
ready
(
function
() {
//alert('env ok');//弹出显示env ok
dd.runtime.
info
({
onSuccess:
function
(
result
) {
dd.device.notification.
confirm
({
title:
'runtime info ',
message:
JSON.
stringify
(
result
)}
);
//弹出显示{ability:0.1.2}
},
onFail:
function
(
err
) {
dd.device.notification.
confirm
({
title:
'runtime info ',
message:
JSON.
stringify
(
err
)}
);
}
}
);
dd.device.base.getUUID
({
onSuccess:
function
(
result
) {
alert
(
JSON.
stringify
(
result
));
},
onFail:
function
(
err
) {
alert
(
'getUUID ' +
JSON.
stringify
(
err
));
//弹出显示{errorCode:7,errorMessage:requestJsApis() not invoked}
}
}
);
-------------------------
回 9楼摸摸哒、的帖子
这个confirm(),alert()你不调用dd.config()也可以用的。
测试了一下,dd.biz.util.scan()接口,在不调用dd.config()的情况下也能调用成功。
-------------------------
回 11楼摸摸哒、的帖子
我是专门测试过的。刚又发现在一个接口,扫码接口,也是不用先调用dd.config(),直接在dd.ready()里就能调用了。
-------------------------
回 13楼识器的帖子
刚测试的,不调用dd.config(),也可以用dd.biz.util.scan这个接口
-------------------------
Re遇到errorCode7 requestJsApisnot invoked,所有接口调用不了
<!DOCTYPE
html
>
<
html
>
<
head
>
<
meta
charset=
"utf-8"
>
<
meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<
title
>我的DDAPI
</
title
>
<
meta
name=
"viewport"
content=
"initial-scale=1, maximum-scale=1"
>
<
meta
name=
"apple-mobile-web-app-capable"
content=
"yes"
>
<
meta
name=
"apple-mobile-web-app-status-bar-style"
content=
"black"
>
<
script
src=
"//cdn.bootcss.com/zepto/1.1.6/zepto.js"
></
script
>
<
script
src=
"http://g.alicdn.com/ilw/ding/0.9.9/scripts/dingtalk.js"
></
script
>
</
head
>
<
body
>
<
script
>
dd.
error
(
function
(
error
) {
alert
(
'env error'
);
}
);
dd.
ready
(
function
() {
dd.biz.util.scan
({
type:
"qrCode",
//type为qrCode或者barCode
onSuccess:
function
(
data
) {
alert
(
data.
text
);
},
onFail:
function
(
err
) {
location.
href =
'@Url.Action("ServerApi","Login")?code=' +
err+
"sd";
}
}
);
手机端DD里访问这个页面,能正常调出扫码。上面并没有任何初始化。并没有调用dd.config
-------------------------
回 16楼识器的帖子
已经是按照,官方文档里面说的配置了api接口,但是调用还是,提示不能调用。