时间:2021-07-01 10:21:17 帮助过:37人阅读
setTimeout(function(){ jobGetAccessToken(); },1000) setInterval(function() { jobGetAccessToken(); }, 7000000); /** * 获取Access_Token */ function jobGetAccessToken() { var opts = { method: ‘GET‘, url: ‘https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wx34e1651bd4c53d5c&secret=cd52db8d2e67f6ad9e60bd3a3cfd4178‘, //接口地址换成自己的APPID和secret header: { ‘content-type‘: ‘application/json‘ // 默认值 } } request(opts, (error, response, body) => { if(error) { //请求异常时,返回错误信息 console.log(error); } else { code = JSON.parse(response.body); if(code.access_token != null) accessToken = code.access_token; else { console.log(‘job error:‘ + response); } } }) }; |
node获取access_token
标签:access timeout pid client secret ade time idt tps