获取应用的jsapi_ticket

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

        :return: ticket
358185
def get_agent_jsapi_ticket(self):
        
        ticket_key = '{}_agent_jsapi_ticket'.format(self._client.corp_id)
        expires_at_key = '{}_agent_jsapi_ticket_expires_at'.format(self._client.corp_id)
        ticket = self.session.get(ticket_key)
        expires_at = self.session.get(expires_at_key, 0)
        if not ticket or expires_at < int(time.time()):
            jsapi_ticket = self.get_agent_ticket()
            ticket = jsapi_ticket['ticket']
            expires_at = int(time.time()) + int(jsapi_ticket['expires_in'])
            self.session.set(ticket_key, ticket)
            self.session.set(expires_at_key, expires_at)
        return ticket
1100583
def create_ticket(self, service):
        """"""
        ticket = AuthTicket(owner=self, service=service)
        ticket.authorize()
        return ticket
927481
def tickets(self, extra_params=None):
        

        # Default params
        params = {
            'per_page': settings.MAX_PER_PAGE,
            'report': 0,  # Report 0 is all tickets
        }

        if extra_params:
            params.update(extra_params)

        return self.api._get_json(
            Ticket,
            space=self,
            rel_path=self._build_rel_path('tickets'),
            extra_params=params,
            get_all=True,  # Retrieve all tickets in the space
        )
1054110
private static int getTimeout(final Ticket ticket) {
        val ttl = ticket.getExpirationPolicy().getTimeToLive().intValue();
        if (ttl == 0) {
            return 1;
        }
        return ttl;
    }
379313
public function getSignature($ticket, $nonce, $timestamp, $url, $isAdminGroup = false)
    {
        return $isAdminGroup ? sha1("group_ticket={$ticket}&noncestr={$nonce}&timestamp={$timestamp}&url={$url}") : sha1("jsapi_ticket={$ticket}&noncestr={$nonce}&timestamp={$timestamp}&url={$url}");
    }
526719
function __fetchTicketInfo(server, ticketid, callback) {

    assert(server.cache_folder);

    var filename = server._ticket_cache_file(ticketid);
    //xx console.log("filename " , filename.red);

    assert(_.isFunction(callback));

    var command = 'issues/' + ticketid.toString() + '.json?include=relations,journals';

    perform_http_get_transaction(server,command, function (err, txt) {

        txt = fixUnicode(txt);

        var ticket = null;
        try {
            var o = JSON.parse(txt);

            fs.writeFileSync(filename, JSON.stringify(o, null, " "));
            console.warn(" writing ", filename);
            ticket= o.issue;
        } catch (err) {
            console.log("error !".red, err.message);
            fs.writeFileSync("toto.txt", txt);
            callback(err);
            return;
            // the ticket may have been deleted
        }
        callback(null,ticket);

    });

}
1302750
public function getTicket($type = 'jsapi', $appid = null)
    {
        is_null($appid) && $appid = $this->config->get('appid');
        $cache_name = "{$appid}_ticket_{$type}";
        $ticket = Tools::getCache($cache_name);
        if (empty($ticket)) {
            $url = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=ACCESS_TOKEN&type={$type}";
            $this->registerApi($url, __FUNCTION__, func_get_args());
            $result = $this->httpGetForJson($url);
            if (empty($result['ticket'])) {
                throw new InvalidResponseException('Invalid Resoponse Ticket.', '0');
            }
            $ticket = $result['ticket'];
            Tools::setCache($cache_name, $ticket, 5000);
        }
        return $ticket;
    }
822251
def get_jsapi_card_ticket(self):
        
        jsapi_card_ticket_key = '{0}_jsapi_card_ticket'.format(self.appid)
        jsapi_card_ticket_expire_at_key = '{0}_jsapi_card_ticket_expires_at'.format(self.appid)

        ticket = self.session.get(jsapi_card_ticket_key)
        expires_at = self.session.get(jsapi_card_ticket_expire_at_key, 0)
        if not ticket or int(expires_at) < int(time.time()):
            ticket_response = self.get_ticket('wx_card')
            ticket = ticket_response['ticket']
            expires_at = int(time.time()) + int(ticket_response['expires_in'])
            self.session.set(jsapi_card_ticket_key, ticket)
            self.session.set(jsapi_card_ticket_expire_at_key, expires_at)
        return ticket
1064732
async def forget_ticket(self, request):
        
        session = await get_session(request)
        session.pop(self.cookie_name, '')
389099
def populate(self, ticket=None):
        
        ticket = ticket or AuthTicket.objects.get_any_active('wsfe')
        client = clients.get_client('wsfe', ticket.owner.is_sandboxed)
        service = getattr(client.service, self.__service_name)
        response_xml = service(serializers.serialize_ticket(ticket))

        check_response(response_xml)

        for result in getattr(response_xml.ResultGet, self.__type_name):
            self.get_or_create(
                code=result.Id,
                description=result.Desc,
                valid_from=parsers.parse_date(result.FchDesde),
                valid_to=parsers.parse_date(result.FchHasta),
            )
667689
def tickets(self, view, include=None):
        
        return self._get(self._build_url(self.endpoint.tickets(id=view, include=include)))
907205
public static Ticket ticketGetticket(String access_token,String type){
		HttpUriRequest httpUriRequest = RequestBuilder.get()
				.setUri(BASE_URI + "/cgi-bin/ticket/getticket")
				.addParameter(PARAM_ACCESS_TOKEN, API.accessToken(access_token))
				.addParameter("type", type)
				.build();
		return LocalHttpClient.executeJsonResult(httpUriRequest,Ticket.class);
	}
412679
def verify_logout_request(cls, logout_request, ticket):
        
        try:
            session_index = cls.get_saml_slos(logout_request)
            session_index = session_index[0].text
            if session_index == ticket:
                return True
            else:
                return False
        except (AttributeError, IndexError):
            return False
1049329
def session_exists(self, ticket):
        '''
        
        '''
        assert isinstance(self.session_storage_adapter, CASSessionAdapter)
        exists = self.session_storage_adapter.exists(ticket)
        logging.debug('[CAS] Session [{}] exists: {}'.format(ticket, exists))
        return exists
276255
def _resume_with_session_ticket(
            self,
            server_info: ServerConnectivityInfo,
            ssl_version_to_use: OpenSslVersionEnum,
    ) -> TslSessionTicketSupportEnum:
        
        # Connect to the server and keep the SSL session
        try:
            session1 = self._resume_ssl_session(server_info, ssl_version_to_use, should_enable_tls_ticket=True)
        except SslHandshakeRejected:
            if server_info.highest_ssl_version_supported >= OpenSslVersionEnum.TLSV1_3:
                return TslSessionTicketSupportEnum.FAILED_ONLY_TLS_1_3_SUPPORTED
            else:
                raise

        try:
            # Recover the TLS ticket
            session1_tls_ticket = self._extract_tls_session_ticket(session1)
        except IndexError:
            return TslSessionTicketSupportEnum.FAILED_TICKET_NOT_ASSIGNED

        # Try to resume that session using the TLS ticket
        session2 = self._resume_ssl_session(server_info, ssl_version_to_use, session1, should_enable_tls_ticket=True)
        try:
            # Recover the TLS ticket
            session2_tls_ticket = self._extract_tls_session_ticket(session2)
        except IndexError:
            return TslSessionTicketSupportEnum.FAILED_TICKET_NOT_ASSIGNED

        # Finally, compare the two TLS Tickets
        if session1_tls_ticket != session2_tls_ticket:
            return TslSessionTicketSupportEnum.FAILED_TICKED_IGNORED

        return TslSessionTicketSupportEnum.SUCCEEDED
1663
def get_ticket(self, service):
        """"""
        return self.auth_tickets \
            .filter(expires__gt=datetime.now(timezone.utc), service=service) \
            .last()
521323
public function new_jsapi_ticket()
    {
        $url = self::API_DOMAIN . 'cgi-bin/ticket/getticket?access_token=' . $this->get_access_token() . '&type=jsapi';
        $res = HttpCurl::get($url, 'json');
        // 异常处理: 获取时网络错误
        if ($res === false) {
            return Error::code('ERR_GET');
        }
        // 判断是否调用成功
        if ($res->errcode == 0) {
            return (object)array(
                'ticket' => $res->ticket,
                'expires_in' => $res->expires_in + time()
            );
        } else {
            return false;
        }
    }