编程知识 cdmana.com

遇到errorCode7 requestJsApisnot invoked,所有接口调用不了

请问怎样查原因?搞了两天了,知道的办法都试过了。就是不知道原因。求救啊。



采纳答案1:
需要在dd.config里配置之后才可以。

-------------------------

最好都要按照文档上来配置,后续校验可能不能通过的。




采纳答案2:
Re遇到errorCode7 requestJsApisnot invoked,所有接口调用不了
dd.ready(function(){

})

这个函数触发了没

-------------------------

Re遇到errorCode7 requestJsApisnot invoked,所有接口调用不了
$(function() {
    $.ajax({
        type : 'get',
        url : 'servlet/configServlet',
        success : function(data) {
            console.log(data);
            data = JSON.parse(data);
            dd.config.agentId = data.agentId;
            dd.config.corpId = data.corpId;
            dd.config.nonceStr = data.noncestr;
            dd.config.timeStamp = data.timestamp;
            dd.config.signature = data.signature;
        },
        error : function(XMLHttpRequest, textStatus, errorThrown) {
            alert(errorThrown);
        },
    });
    dd.config({
        agentId : '', // 必填,微应用ID
        corpId : '',
        timeStamp : '', // 必填,生成签名的时间戳
        nonceStr : '', // 必填,生成签名的随机串
        signature : '', // 必填,签名
        jsApiList : [ 'device.notification.alert',
                'device.notification.confirm','biz.chat.chooseConversationByCorpId','biz.chat.pickConversation',
                'runtime.info','runtime.permission.requestAuthCode','device.base.getUUID','device.base.getInterface',
                'device.nfc.nfcRead'
                
                
                ]
    // 必填,需要使用的jsapi列表
    });
    
    
    dd.ready(function() {
        
        dd.device.notification.confirm({
            message : "你爱我吗",
            title : "提示",
            buttonLabels : [ '爱', '不爱' ],
            onSuccess : function(result) {
                 //alert(result.buttonIndex)
            },
            onFail : function(err) {
            }
        });
        })

-------------------------

回 10楼人在囧途的帖子
不可能的吧,验证不通过不可能调用的



采纳答案3:
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接口,但是调用还是,提示不能调用。

版权声明
本文为[阿里云问答]所创,转载请带上原文链接,感谢
https://developer.aliyun.com/ask/243050

Scroll to Top