/** * 请求服务器jsapi_ticket * @param string $type * @return array|bool */ protected function requestJsApiTicket($type = 'jsapi') { $http = new Http(); $result = $http->httpGet(self::WECHAT_JS_API_TICKET_PREFIX, ['access_token' => $this->getAccessToken(), 'type' => $type]); return isset($result['ticket']) ? $result : false; }
/** * 检验授权凭证(access_token)是否有效 * @param $accessToken * @param $openId * @return bool */ public function checkOauth2AccessToken($accessToken, $openId) { $http = new Http(); $result = $http->httpGet(self::WECHAT_SNS_AUTH_PREFIX, ['access_token' => $accessToken, 'openid' => $openId]); return isset($result['errmsg']) && $result['errmsg'] == 'ok'; }