本文整理匯總了PHP中QC::callback方法的典型用法代碼示例。如果您正苦於以下問題:PHP QC::callback方法的具體用法?PHP QC::callback怎麽用?PHP QC::callback使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類QC
的用法示例。
在下文中一共展示了QC::callback方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: wxcallback
public function wxcallback()
{
$this->load->model('user');
$this->load->model('user_openid');
require_once APPPATH . "libraries/WXAPI/wxConnectAPI.php";
$qc = new QC();
$param = $qc->callback();
//$openid = $qc->get_openid();
$useropenid = $this->user_openid->get_by_openid($param['openid']);
if (isset($useropenid->user_id) && $useropenid->user_id > 0) {
$this->user_openid->update(array('token' => $param['access_token'], 'expires' => local_to_gmt() + $param['expires_in'], 'refresh_token' => $param['refresh_token']), $useropenid->id);
$user = $this->user->get($useropenid->user_id);
$login_time = local_to_gmt();
$update_row['last_login_time'] = $login_time;
$update_row['last_login_ip'] = $this->input->ip_address();
//自動保留登錄15天
$this->auth->set_auto_login($user->username, $user->password);
if (isset($_COOKIE['lms_logout_url'])) {
$url = $_COOKIE['lms_logout_url'];
setcookie('lms_logout_url', '', time() - 3600, '/');
} else {
$url = base_url();
}
$this->user->update($update_row, $user->id);
//保存session
$this->auth->save_login($user);
redirect($url);
} else {
if (!$useropenid) {
if ($this->user_openid->insert(array('name' => 'weixin', 'token' => $param['access_token'], 'openid' => $param['openid'], 'create_time' => local_to_gmt(), 'expires' => local_to_gmt() + $param['expires_in'], 'refresh_token' => $param['refresh_token']))) {
redirect('register/openid/' . $param['openid']);
} else {
redirect('login/error/login_error');
}
} else {
redirect('register/openid/' . $param['openid']);
}
}
}