Code Monkey home page Code Monkey logo

Comments (6)

zqj avatar zqj commented on June 5, 2024

测试代码:redis这块很不稳定
weixin_client ||= WeixinAuthorize::Client.new(weixin_public_no.appID, weixin_public_no.appsecret)
if weixin_client.is_valid?
followers = weixin_client.followers

  Rails.logger.debug followers.class

  if followers
    Rails.logger.info followers.to_s
    if followers["data"]
      followers["data"]["openid"].each do |openid|
        weixin_user = weixin_client.user(openid)
        Rails.logger.debug weixin_user.to_s
      end
    end
  end
  #user_info = $client.user(ENV["OPENID"])
end

from weixin_authorize.

zqj avatar zqj commented on June 5, 2024

第一次可以正常获取到followers,第二次后面就不行了

from weixin_authorize.

lanrion avatar lanrion commented on June 5, 2024

weixin_client.is_valid? 在保存或者更新公众账号的 appid 和 appsecret时才调用,第一次验证都成功了,那么以后的操作肯定是对的,所以不需要每次调用API时都跑一次is_valid?验证。。

from weixin_authorize.

lanrion avatar lanrion commented on June 5, 2024

主要原因是,第二次调用`is_valid?`时,会重新获取access_token,之前保存在redis的access_token就失效了,之后再调用API,会继续使用 redis里失效的access_token,所以微信会返回40001,表示access_token是无效的。
一般是建议只在用户保存或者更新appid 和app_secret时才做一次 is_valid?

下午会修复:is_valid? 应该是要随时都可以调用,是比较严重的bug.

谢谢。

from weixin_authorize.

lanrion avatar lanrion commented on June 5, 2024

使用master 测试一下。

from weixin_authorize.

lanrion avatar lanrion commented on June 5, 2024

相关测试见:
https://github.com/lanrion/weixin_authorize/blob/master/spec/api/user_spec.rb#L9

from weixin_authorize.

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.