Comments (2)
用redis吧
发自我的 iPhone
在 2015年10月20日,下午6:12,李政 [email protected] 写道:
按照代码,调用getLatestToken获取不到token的。像示例一样把access_token写入文件的话,这个文件是要我手动初始化写入内容?
var api = new API('appid', 'secret', function (callback) {
// 传入一个获取全局token的方法
fs.readFile('access_token.txt', 'utf8', function (err, txt) {
if (err) {return callback(err);}
callback(null, JSON.parse(txt));
});
}, function (token, callback) {
// 请将token存储到全局,跨进程、跨机器级别的全局,比如写到数据库、redis等
// 这样才能在cluster模式及多机情况下使用,以下为写入到文件的示例
fs.writeFile('access_token.txt', JSON.stringify(token), callback);
});
—
Reply to this email directly or view it on GitHub.
from wechat-api.
看了源代码,无论是保存到哪,在get函数里必须把回调的参数设为空对象{}
才能触发重新获取access_token。
from wechat-api.
Related Issues (20)
- WeChatAPIJSONResponseFormatError
- 无限重复的post请求 HOT 2
- 什么时候能支持发送【小程序】图文链接? HOT 2
- lib/api_metrial.js HOT 1
- 上传永久素材
- 永久二维码现在支持字符串形式了 希望更新 HOT 1
- getMaterial 接口返回Buffer HOT 1
- WeChatAPIError: 40001
- 40001错误 HOT 1
- Error code: 48001, message: api unauthorized HOT 2
- 如何把 getMaterial 返回的 Buffer 保存为文件? HOT 2
- 上传多媒体的接口貌似不通了, 望你们测试一下 HOT 1
- Error code: 48001: unauthorized api in wechat shop HOT 1
- 希望可以支持下typescript HOT 1
- domain doxmate.cool is expired HOT 4
- 获取二维码地址后,上传到临时素材报错,望指导。 HOT 1
- api文档错误 HOT 1
- 支持MAC和IPAD协议新微信号接入,做机器人,营销系统,客服系统,监管系统的可以看下这个API :http://www.bbaos.com/docs/index HOT 1
- 找不到 doxmate.cool 的服务器 IP 地址。 HOT 1
- 需要最新iPAD协议联系(v:ixiaohe_) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wechat-api.