python 怎么判断其token时效性
getset_token.py文件(获取token):程序代码:
import urllib.parse import urllib.request import json import datetime url='https://api.weixin.' data={'appid':'*******************', 'secret':'************************************'} data=urllib.parse.urlencode(data).encode('utf-8') request=urllib.request.urlopen(url,data) html= request.read() tokenandtime=json.loads(html) access_token=tokenandtime['access_token'] expires_in=tokenandtime['expires_in'] #token时效=7200
selectmenu.py(查询菜单接口):
程序代码:
import urllib.request import getset_token import json token = getset_token.access_token url = 'https://api.weixin.' + token request = urllib.request.urlopen(url) html=request.read() data_dict=json.loads(html)
微信的token令牌为7200秒,我怎么再调用接口的时候去验证token令牌是否过期? 具体怎么实现