获取微信公众号 jsapi_ticket
@param $app_id 微信公众号应用唯一标识
@param $app_secret 微信公众号应用密钥（注意保密）
@return array 包含 jsapi_ticket 的数组或者错误信息
326270
public static function getJsapiTicket($app_id, $app_secret) {
        $urlObj = array();
        $urlObj['appid'] = $app_id;
        $urlObj['secret'] = $app_secret;
        $urlObj['grant_type'] = 'client_credential';
        $queryStr = http_build_query($urlObj);
        $accessTokenUrl = 'https://api.weixin.qq.com/cgi-bin/token?' . $queryStr;
        $resp = self::_getRequest($accessTokenUrl);
        $resp = json_decode($resp, true);
        if (!is_array($resp) || isset($resp['errcode'])) {
            return $resp;
        }

        $urlObj = array();
        $urlObj['access_token'] = $resp['access_token'];
        $urlObj['type'] = 'jsapi';
        $queryStr = http_build_query($urlObj);
        $jsapiTicketUrl = 'https://api.weixin.qq.com/cgi-bin/ticket/getticket?' . $queryStr;
        $resp = self::_getRequest($jsapiTicketUrl);

        return json_decode($resp, true);
    }
864510
public function getAuthorizerInfo($authorizer_appid)
    {
        $params = array(
            'component_appid'  => $this->appid,
            'authorizer_appid' => $authorizer_appid,
        );

        return $this->http->jsonPost(self::API_GET_AUTHORIZER_INFO, $params);
    }
339889
public static function getRoleIdByAppIdAndUserId($app_id, $user_id)
    {
        $cacheKey = static::makeRoleIdCacheKey($app_id, $user_id);
        $result = \Cache::remember($cacheKey, \Config::get('df.default_cache_ttl'),
            function () use ($app_id, $user_id) {
                try {
                    return static::whereAppId($app_id)->whereUserId($user_id)->value('role_id');
                } catch (ModelNotFoundException $ex) {
                    return null;
                }
            });

        return $result;
    }
1228101
public function checkClientCredentials($client_id, $client_secret = null)
    {
        if ($result = $this->getObjectByType('client_table',$client_id)) {
            return $result['client_secret'] == $client_secret;
        }

        return false;
    }
760855
public function wxCardPackage(array $card_list, $timestamp = null, $api_ticket = null)
    {
        if (!is_array($card_list)) {
            $this->setError('参数缺失');

            return false;
        }

        if (empty($timestamp) || $timestamp == '') {
            $timestamp = time();
        }

        if (empty($api_ticket) || $api_ticket == '') {
            $api_ticket = $this->cardApiTicket();
        }

        $resultArray = [];
        foreach ($card_list as $key => $value) {
            if (empty($value['code']) || !isset($value['code'])) {
                $value['code'] = '';
            }
            if (empty($value['openid']) || !isset($value['openid'])) {
                $value['openid'] = '';
            }
            $arrays = [$api_ticket, $timestamp, $value['card_id'], $value['code'], $value['openid']];
            sort($arrays, SORT_STRING);
            $string = sha1(implode($arrays));

            $resultArray['cardList'][$key]['cardId']            = $value['card_id'];
            $resultArray['cardList'][$key]['cardExt']['code']   = $value['code'];
            $resultArray['cardList'][$key]['cardExt']['openid'] = $value['openid'];

            $resultArray['cardList'][$key]['cardExt']['timestamp'] = $timestamp;
            $resultArray['cardList'][$key]['cardExt']['signature'] = $string;

            if (!empty($value['outer_id'])) {
                $resultArray['cardList'][$key]['cardExt']['outer_id'] = $value['outer_id'];
            }
            $resultArray['cardList'][$key]['cardExt'] = json_encode($resultArray['cardList'][$key]['cardExt']);
        }
        $resultJson = json_encode($resultArray);

        return $resultJson;
    }
378208
public function getJsSign($url, $appid = null, $ticket = null)
    {
        list($url,) = explode('#', $url);
        is_null($ticket) && $ticket = $this->getTicket('jsapi');
        is_null($appid) && $appid = $this->config->get('appid');
        $data = ["url" => $url, "timestamp" => '' . time(), "jsapi_ticket" => $ticket, "noncestr" => Tools::createNoncestr(16)];
        return [
            'debug'     => false,
            "appId"     => $appid,
            "nonceStr"  => $data['noncestr'],
            "timestamp" => $data['timestamp'],
            "signature" => $this->getSignature($data, 'sha1'),
            'jsApiList' => [
                'updateAppMessageShareData', 'updateTimelineShareData', 'onMenuShareTimeline', 'onMenuShareAppMessage', 'onMenuShareQQ', 'onMenuShareWeibo', 'onMenuShareQZone',
                'startRecord', 'stopRecord', 'onVoiceRecordEnd', 'playVoice', 'pauseVoice', 'stopVoice', 'onVoicePlayEnd', 'uploadVoice', 'downloadVoice',
                'chooseImage', 'previewImage', 'uploadImage', 'downloadImage', 'translateVoice', 'getNetworkType', 'openLocation', 'getLocation',
                'hideOptionMenu', 'showOptionMenu', 'hideMenuItems', 'showMenuItems', 'hideAllNonBaseMenuItem', 'showAllNonBaseMenuItem',
                'closeWindow', 'scanQRCode', 'chooseWXPay', 'openProductSpecificView', 'addCard', 'chooseCard', 'openCard',
            ],
        ];
    }
1254742
public function getAppsAsync($org_id = null, $name = null)
    {
        return $this->getAppsAsyncWithHttpInfo($org_id, $name)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }
973268
public function getTickets($accountID, $page = 1)
    {
        $result = $this->httpHelper->get("/accounts/" . intval($accountID) . "/tickets", $page);
        $tickets = [];
        foreach ($result as $datum)
        {
            if ($datum->type !== "public")
            {
                continue;
            }
            $ticket = new Ticket([
                'subject' => $datum->subject,
                'ticket_group_id' => $datum->ticket_group_id,
                'user_id' => $datum->user_id,
                'account_id' => $datum->assignee_id,
                'priority' => $datum->priority,
                'open' => $datum->open,
                'inbound_email_account_id' => $datum->inbound_email_account_id,
                'email_address' => $datum->email_address,
                'ticket_id' => $datum->id,
                'last_reply_incoming' => $datum->last_reply_incoming,
            ]);
            array_push($tickets, $ticket);
        }

        return $tickets;
    }
1332745
def auth_app(self, app_id, app_secret, auth_code, state=''):
        
        headers = {
            'Content-type': 'application/json'
        }
        payload = {
            'application': app_id,
            'auth_code': auth_code,
            'state': state
        }
        try:
            full_url = utils.urljoin(
                self.host,
                '/api/v1/application-tokens/validate'
            )
            response = requests.post(
                full_url,
                data=json.dumps(payload),
                headers=headers,
                verify=self.tls_verify
            )
        except RequestException:
            raise exceptions.TaigaRestException(
                full_url, 400,
                'NETWORK ERROR', 'POST'
            )
        if response.status_code != 200:
            raise exceptions.TaigaRestException(
                full_url,
                response.status_code,
                response.text,
                'POST'
            )
        cyphered_token = response.json().get('cyphered_token', '')
        if cyphered_token:
            from jwkest.jwk import SYMKey
            from jwkest.jwe import JWE

            sym_key = SYMKey(key=app_secret, alg='A128KW')
            data, success = JWE().decrypt(cyphered_token, keys=[sym_key]), True
            if isinstance(data, tuple):
                data, success = data
            try:
                self.token = json.loads(data.decode('utf-8')).get('token', None)
            except ValueError:  # pragma: no cover
                self.token = None
            if not success:
                self.token = None
        else:
            self.token = None

        if self.token is None:
            raise exceptions.TaigaRestException(
                full_url, 400,
                'INVALID TOKEN', 'POST'
            )

        self.raw_request = RequestMaker('/api/v1', self.host, self.token,
                                        'Application', self.tls_verify)
        self._init_resources()
162404
static public function isAuth($app_id) {

		$session = array();
		$member = false;
		$valid_keys = array('expire', 'mid', 'secret', 'sid', 'sig');
		$app_cookie = $_COOKIE['vk_app_' . $app_id];
		if( $app_cookie ) {
			$session_data = explode('&', $app_cookie, 10);
			foreach( $session_data as $pair ) {
				list($key, $value) = explode('=', $pair, 2);
				if( empty($key) || empty($value) || !in_array($key, $valid_keys) ) {
					continue;
				}
				$session[$key] = $value;
			}
			foreach( $valid_keys as $key ) {
				if( !isset($session[$key]) ) {
					return $member;
				}
			}
			ksort($session);

			$sign = '';
			foreach( $session as $key => $value ) {
				if( $key != 'sig' ) {
					$sign .= ($key . '=' . $value);
				}
			}
			$sign .= $app_id;
			$sign = md5($sign);
			if( $session['sig'] == $sign && $session['expire'] > time() ) {
				$member = array(
					'id'     => intval($session['mid']),
					'secret' => $session['secret'],
					'sid'    => $session['sid']
				);
			}
		}

		return (object)array(
			'member'  => $member,
			'session' => $session
		);
	}
52619
def show(cls, app_id):
        
        conn = Qubole.agent()
        return conn.get(cls.element_path(app_id))
951513
public function getActivateMemberCardTempinfo($activate_ticket)
    {
        $url = 'https://api.weixin.qq.com/card/membercard/activatetempinfo/get?access_token=ACCESS_TOKEN';
        $this->registerApi($url, __FUNCTION__, func_get_args());
        return $this->httpPostForJson($url, ['activate_ticket' => $activate_ticket]);
    }
1244799
public function getConfigData(array $jsApiList, $url = null)
    {
        $api = $this->createApiService();
        $jsApiTicket = $api->getApiTicketFromCache('jsapi');

        $timestamp = time();
        $nonceStr = $this->generateNonceStr(32);
        $url || $url = $this->request->getUrl();

        $signData = [
            'jsapi_ticket' => $jsApiTicket,
            'noncestr' => $nonceStr,
            'timestamp' => $timestamp,
            'url' => $url,
        ];
        $signature = sha1($api->generateSign($signData));

        return [
            'beta' => true, // 开启内测接口,用于微信硬件
            'debug' => $this->wei->isDebug(),
            'appId' => $this['applicationId'],
            'timestamp' => $timestamp,
            'nonceStr' => $nonceStr,
            'signature' => $signature,
            'jsApiList' => $jsApiList,
        ];
    }
1224460
@GetMapping(value = "/v1/tickets/{id:.+}")
    public ResponseEntity<String> getTicketStatus(@PathVariable("id") final String id) {
        try {
            val ticket = this.centralAuthenticationService.getTicket(id);
            return new ResponseEntity<>(ticket.getId(), HttpStatus.OK);
        } catch (final InvalidTicketException e) {
            return new ResponseEntity<>("Ticket could not be found", HttpStatus.NOT_FOUND);
        } catch (final Exception e) {
            LOGGER.error(e.getMessage(), e);
            return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
        }
    }
1284612
public function get_jsapi_ticket()
    {
        $ticket = false;
        if ($this->get_jsapi_ticket_diy !== false) {
            // 调用用户自定义获取jsapi_ticket方法
            $ticket = call_user_func($this->get_jsapi_ticket_diy);
            if ($ticket) {
                $ticket = json_decode($ticket);
            }
        } else {
            // 异常处理: 获取jsapi_ticket方法未定义
            @error_log('Not set getTicketDiy method, jsapi_ticket will be refreshed each time.', 0);
        }

        // 验证jsapi_ticket是否有效
        if (!$this->valid_jsapi_ticket($ticket)) {

            // 生成新的jsapi_ticket
            $ticket = $this->new_jsapi_ticket();
            if ($ticket === false) {
                return false;
            }

            // 保存新生成的AccessToken
            if ($this->save_jsapi_ticket_diy !== false) {
                // 用户自定义保存AccessToken方法
                call_user_func($this->save_jsapi_ticket_diy, json_encode($ticket));
            } else {
                // 异常处理: 保存access_token方法未定义
                @error_log('Not set saveTokenDiy method, jsapi_ticket will be refreshed each time.', 0);
            }
        }
        return $ticket->ticket;
    }
791144
public function getOauthUserInfo($access_token, $openid)
    {
        $result = Tools::httpGet(self::API_BASE_URL_PREFIX . self::OAUTH_USERINFO_URL . "access_token={$access_token}&openid={$openid}");
        if ($result) {
            $json = json_decode($result, true);
            if (empty($json) || !empty($json['errcode'])) {
                $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505';
                $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容！';
                Tools::log("WechatOauth::getOauthUserInfo Fail.{$this->errMsg} [{$this->errCode}]", "ERR - {$this->appid}");
                return false;
            }
            return $json;
        }
        return false;
    }
504947
private function checkKey()
    {
        $keyResource = openssl_get_publickey($this->secretKey);
        $details = openssl_pkey_get_details($keyResource);

        if (!isset($details["key"]) || $details["type"] !== OPENSSL_KEYTYPE_RSA) {
             throw new AppException("Provided Secret Key is invalid");
        }
    }