Git Product home page Git Product logo

Comments (2)

JacksonTian avatar JacksonTian commented on July 16, 2024

用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.

airyland avatar airyland commented on July 16, 2024

看了源代码,无论是保存到哪,在get函数里必须把回调的参数设为空对象{}才能触发重新获取access_token。

from wechat-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.