You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.5 KiB

2 months ago
<?php
/**
*
*/
2 months ago
include_once(dirname(dirname(__FILE__)) . "/library/publicBase.php");
2 months ago
class callback extends publicBase {
public function wxlogin() {
2 months ago
if (empty($this->get('code'))) $this->show_message('登录失败,请重新登录', 'goback');
2 months ago
$state = explode('-', $this->get('state'));
2 months ago
//知识库登陆
2 months ago
if ($state[0] == CALLBACK_KNOWLEDGE_LOGIN) {
$obj = new mManage();
$res = $obj->weixinLogin($this->get('code'), $this->get('state'));
if (!$res) $this->show_message($obj->getError(), 'goback');
session_start();
2 months ago
$_SESSION['nickname'] = $res['nickname'];
2 months ago
$_SESSION['openid'] = $res['openid'];
$_SESSION['token'] = $res['jwttoken'];
session_write_close();
2 months ago
header('Location:' . urldecode($state[1]));
2 months ago
exit;
}
2 months ago
//知识库绑定
if ($state[0] == CALLBACK_KNOWLEDGE_BIND) {
$obj = new mManage();
$sub_user_id = $obj->weixinBind($this->get('code'), $this->get('state'));
if (!$sub_user_id) $this->show_message($obj->getError(), 'goback');
$obj = new mUser();
$rdobj = $obj->initRedis();
$rdobj->setex(sprintf(_RC_KNOWLEDGE_BIND_USER_INFO, $state[1], $state[2]), 6*60*60, $sub_user_id);
2 months ago
header('Location:http://zhishiku.yizherenxin.cn/index/bind_user?pageid='.$state[2]);
2 months ago
exit;
}
2 months ago
exit;
}
}