V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
ninestep
V2EX  ›  微信

多个系统共用一个微信公众号,在上传图片的时候会返回 access_token 过期,怎么解决?

  •  
  •   ninestep · Nov 19, 2016 · 4402 views
    This topic created in 3446 days ago, the information mentioned may be changed or developed.

    开发的多个系统需要调用同一个微信公众号,但是上传图片的时候会出现s:110:"{"errcode":40001,"errmsg":"invalid credential, access_token is invalid or not latest hint: [J3U7wA0390vr31!]"}"; 的错误,你们有没有遇到?有什么好的解决方法?

    3 replies    2016-11-19 22:13:28 +08:00
    sarices
        1
    sarices  
       Nov 19, 2016
    做一个获取 access_token 的服务,大家共用,或者降 access_token 放到 memcached 中
    shiny
        2
    shiny  
    PRO
       Nov 19, 2016
    access_token 只能同时存在一个,每次申请会让之前那个失效。
    所以 #1 是正确做法。

    同时每次应该对 40001 的错误事件做个刷新 token 和重试的策略,不要太依赖 expire 的时间。
    ninestep
        3
    ninestep  
    OP
       Nov 19, 2016
    @sarices 好的,我明天上班试试
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3632 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 10:47 · PVG 18:47 · LAX 03:47 · JFK 06:47
    ♥ Do have faith in what you're doing.