微信get请求token_access 疑问(菜鸟勿喷)
发布于 8 年前 作者 majamping 5176 次浏览 来自 问答

提示一下,如何将返回结果格式化为: {“access_token”:“ACCESS_TOKEN”,“expires_in”:7200}, 实际返回有header内容,哪一位可以提示一下。

var https = require(‘https’); var options={ hostname:“api.weixin.qq.com”, path:"/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET", method:‘GET’ }; var req = https.request(options, function(res) { console.log( res.headers); res.on(‘data’, function(d) { process.stdout.write(d); }); }); req.end(); req.on(‘error’, function(e) { console.error(e); });

1 回复

var options={ hostname:“api.weixin.qq.com“, path:”/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET”, json: true // 此处添加选项 method:‘GET’ };

回到顶部