def get_jsapi_ticket(self):
ticket_key = '<STR_LIT>'.format(self.appid)<EOL>expires_at_key = '<STR_LIT>'.format(self.appid)<EOL>ticket = self.session.get(ticket_key)<EOL>expires_at = self.session.get(expires_at_key, <NUM_LIT:0>)<EOL>if not ticket or expires_at < int(time.time()):<EOL><INDENT>jsapi_ticket_response = self.get_ticket('<STR_LIT>')<EOL>ticket = jsapi_ticket_response['<STR_LIT>']<EOL>expires_at = int(time.time()) + int(jsapi_ticket_response['<STR_LIT>'])<EOL>self.session.set(ticket_key, ticket)<EOL>self.session.set(expires_at_key, expires_at)<EOL><DEDENT>return ticket<EOL>
获取微信 JS-SDK ticket

该方法会通过 session 对象自动缓存管理 ticket

:return: ticket