https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential, 请求这个方法获取access_token并加入redis缓存, 在有效期内从缓存中获取token并调用获取手机号接口, 返回失败, 请求参数和返回参数如下
url:https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=90_qXVsKHzRHCEG**********BAACC requestParam:{"code":"562f6db7e4ec0c1884992fc605**********cb0a772a6bc7d9716926"} requestHeaders:{"Content-Type":"application/json"} http code :200 cost:195 result :{"errcode":40001,"errmsg":"invalid credential, access_token is invalid or not latest, could get access_token by getStableAccessToken, more details at https://mmbizurl.cn/s/JtxxFh33r rid: 67cfdb4b-1e125ece-1fc7654e"}
你可以建立一个表,放进去,时间设定两个小时,每次访问如果在这个时间段就直接用,如果不在更新获取,重新设定时间。
密钥泄露了,导致token争抢