-
Notifications
You must be signed in to change notification settings - Fork 328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
每次调用任何接口,access token就会被刷新一次 #232
Comments
没有正确使用。 |
比如 var wechat_api = new API(keystone.get('appid'), keystone.get('appsecret'),function(callback){
//获取token的函数
token.model.findOne().exec(function(err, result) {
if (result != null){
keystone.set('access_token',result.content);
console.log("[wechat]reading token :"+result.content);
callback(null,result.content);
} else {
callback(err);
}
});
},function(newtoken,callback){
token.model.remove(function(){
var newToken = new token.model({
content: newtoken.accessToken,
});
newToken.save(function(){
keystone.set('access_token',newtoken.accessToken);
console.log("[wechat]token has been saved :"+newtoken.accessToken);
callback();
});
});
}); wechat_api.xxxx(); |
看起来木有错啊。 |
然后我在代码下面调用wechat_api时就发现每次都会重新拿一个token |
应该是 callback(null,result.content); content的格式不对。 要求的格式如下:
|
检查一下第三个参数(回调函数)里面写的result.content的格式,要符合 {
accessToken:"XXXXX",
expireTime: 毫秒数
} |
var WechatAPI = require('wechat-api'); 官方的这个例子,跑了很多次,一直报错 |
@zhu5439peng 有区别? |
我用的构建函数是带了存入和取出token的,为什么每次调用任何接口,token就会被刷新一次
The text was updated successfully, but these errors were encountered: