authUrl .'?appid='.$this->wechat->appId.'&redirect_uri=' . $redirectUrl . '&scope='.$scope.'&response_type=code&state=1#wechat_redirect'; return $authUrl; } //获得access_token public function getAccessToken($code) { $tokenUrl = $this->tokenUrl.'?appid='.$this->wechat->appId.'&secret='.$this->wechat->appSecret.'&code='.$code.'&grant_type=authorization_code'; $this->wechat->curl->get($tokenUrl); $res = json_decode($this->wechat->curl->response, true); return $res; } //获得用户信息 public function getUserInfo($access_token,$openid) { $userInfoUrl = $this->userInfoUrl.'?access_token='.$access_token.'&openid='.$openid; $this->wechat->curl->get($userInfoUrl); $res = json_decode($this->wechat->curl->response, true); return $res; } //refresh_token public function getRefreshToken($refreshToken) { $refreshTokenUrl = $this->refreshTokenUrl.'?appid='.$this->wechat->appId.'&grant_type=refresh_token&refresh_token='.$refreshToken; $this->wechat->curl->get($refreshTokenUrl); $res = json_decode($this->wechat->curl->response, true); return $res; } }