def get_token(self):
"""Get wechat access token.Store in cache"""
access_token = cache.get('wx_access_token')
if access_token:
return access_token
else:
param = {
'grant_type': 'client_credential',
'appid': self.appid,
'secret': self.appsecret,
}
url = self.get_url('token', param)
data = self.get_data(url)
cache.set('wx_access_token', data['access_token'],\
int(data['expires_in']))
return data['access_token']
评论列表
文章目录