public function successCallback($client) { $mTplogin = new UserThirdPartyLogin(); $id = $client->getId(); $key = $client->openid(); $userAttrs = $client->getUserAttributes(); $userProfile = $client->getUserInfo(); $openid = $userAttrs[$key]; // TODO: 需要调整为获取当前登录用户 $userid = 100; $data = ['type' => $id, 'user_id' => $userid, 'open_id' => $openid, 'profile_info' => json_encode($userProfile)]; if (isset($userAttr['expire_in'])) { $data['expire_time'] = $userAttr['expire_in']; } try { if (!$mTplogin->checkBindByOpenid($openid, $userid)) { if ($userAr = $mTplogin->bind($data)) { $userAr['profile'] = $userProfile; $this->setTplSessionToUser($userAr); } else { // TODO: 绑定失败 } } else { $this->setTplSessionToUser(['type' => $id, 'open_id' => $openid, 'profile' => $userProfile]); // TODO: 已经绑定 } } catch (oxception $e) { // TODO: 登录异常 } }