<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                >[danger]每次訪問接口時,都必須攜帶5個公共參數,如果需要用戶信息的接口,還需要攜帶cowcms_userid參數(建議每個連接都攜帶該參數) | 參數名稱 | 參數描述 | | --- | --- | | appid | 接口網站分配個請求網站的appid | | interval | timestamp參數有效時時長 默認7200,單位為秒 | | timestamp | 請求時間戳,該值和當前時間差不能大于 interval 值(默認7200秒,時間在后臺可設置) | | nonceStr | 隨機字符串 | | signature | 請求簽名 | | cowcms_userid | 登錄用戶id 32位字符串,該參數在用戶登錄時,返回給前端的用戶登錄憑證,前端需要保存該憑證,在調用強制用戶登錄的接口時必傳該參數 | >[danger]調用API接口流程 1.獲取訪問API接口的必須參數。 2.將獲取的參數緩存到前端。 3.訪問接口時判定必須參數是否在有效時間內 4.如果參數有效直接訪問,如果參數無效,重新獲取然參數后,執行第二步 >站內調用接口獲取訪問API接口的必須參數 ``` namespace app\user\controller; use user\Member; class Sign extends Member { function getCowcmsUserid() { //$id API站點id,如果是本站默認id為1,開發者可根據自己需求填寫 $param = exeFun('getApiParam',[$id=1],'api'); dump($param) ; } } $param打印出來的參數為 array(5) { ["appid"] => string(40) "50fb0e2cde242fb428e5d35c719e82f3bfca8dcf" ["timestamp"] => int(1584416641) ["nonceStr"] => string(6) "gtug8k" ["signature"] => string(40) "fcee23aa9c3f9055d8d63e4cba51d71a630a03a3" ["interval"] => int(7200) } ``` >其它網站訪問接口獲取必須參數 ``` namespace app\user\controller; use user\Member; class Sign extends Member { function getCowcmsUserid() { $url = "http://xxxx.com/public/index.php/api/Apiget/get_param/appid/XXX/appsecret/XXXX/token/xxx" $param = http_curl($url); dump($param); } } $param打印出來的參數為 array(5) { ["appid"] => string(40) "50fb0e2cde242fb428e5d35c719e82f3bfca8dcf" ["timestamp"] => int(1584416641) ["nonceStr"] => string(6) "gtug8k" ["signature"] => string(40) "fcee23aa9c3f9055d8d63e4cba51d71a630a03a3" ["interval"] => int(7200) } ``` >[danger]自行生成訪問接口獲取必須參數,將 appid,appsecret,timestamp,nonceStr參數按照字典排序用&連接,進行(sha1或者md5,此處主要看后臺設置加密類型)加密生成signature簽名,如: signature =sha1(appid=6a9f5b5a0cd0594731113041f989e2a3a27afbcb&appsecret=aa0d037bfd95978e154aecb75739295681060346&nonceStr=8UsD7F&timestamp=1586238156) 2.將獲取的參數緩存到前端 ``` localStorage.setItem("appid","...."); localStorage.setItem("timestamp","...."); localStorage.setItem("nonceStr","...."); localStorage.setItem("signature","...."); localStorage.setItem("interval","...."); ``` 3.js每次訪問接口時,檢測timestamp是否失效,如果失效重新獲取參數,并緩存數據,否則訪問接口 ``` appid = localStorage.getItem("appid"); timestamp = localStorage.getItem("timestamp"); nonceStr = localStorage.getItem("nonceStr"); signature = localStorage.getItem("signature"); interval = localStorage.getItem("interval"); timestamp = (new Date()).getTime();; //當前時間戳 //提前10秒兌換新的參數 if(time - timestamp - interval > 10) { //參數失效,并重新獲取 url = "http://xxxx.com/public/index.php/api/Apiget/get_param_change"; param= {appid:'50fb0e2cde242fb428e5d35c719e82f3bfca8dcf',timestamp:1584418592,nonceStr:'IYI0wK',signature:'d3c512eef5bc25d09b767e75b8f5eff3bd91bec8'}; $.getJSON(url,param, function(json){ localStorage.setItem("appid","...."); localStorage.setItem("timestamp","...."); localStorage.setItem("nonceStr","...."); localStorage.setItem("signature","...."); localStorage.setItem("interval","...."); }); } ``` >cowcms_userid值的獲取 方式 當用戶登錄后由后端返回
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看