...
|
...
|
@@ -373,12 +373,11 @@ class LoginController extends HomeBaseController |
|
|
$token = $json_arr['access_token'];
|
|
|
$openid = $json_arr['openid'];
|
|
|
//通过access_token获取用户信息
|
|
|
$url1 = 'https://api.weixin.qq.com/sns/userinfo?access_token='.$token.'&openid='.$openid;
|
|
|
$url1 = 'https://api.weixin.qq.com/sns/userinfo?access_token='.$token.'&openid='.$openid.'&lang=zh_CN';
|
|
|
$res1 = $this->http_get($url1);
|
|
|
$info = json_decode($res1,true);
|
|
|
var_dump($info);exit;
|
|
|
//查询该微信用户是否存在
|
|
|
$where = ['wb_id'=>$info['openid'],'source'=>'微信'];
|
|
|
$where = ['wb_id'=>$info['unionid'],'source'=>'微信'];
|
|
|
$user = $this->findThird($where);
|
|
|
//获取微博id,昵称,头像
|
|
|
$userModel = new UserModel();
|
...
|
...
|
@@ -390,7 +389,7 @@ class LoginController extends HomeBaseController |
|
|
$users['avatar'] = $info['headimgurl'];
|
|
|
$userModel->where(['wb_id'=>$info['openid'],'source'=>'微信'])->update($users);
|
|
|
}else{
|
|
|
$users['wb_id'] = $info['openid'];
|
|
|
$users['wb_id'] = $info['unionid'];
|
|
|
$users['user_nickname'] = $info['nickname'];
|
|
|
$users['avatar'] = $info['headimgurl'];
|
|
|
$users['source'] = '微信';
|
...
|
...
|
@@ -413,7 +412,6 @@ class LoginController extends HomeBaseController |
|
|
//用户登录
|
|
|
$this->redirect('/portal/login/login');
|
|
|
}
|
|
|
var_dump($json_arr);
|
|
|
$token = $json_arr['access_token'];
|
|
|
$openid = $json_arr['openid'];
|
|
|
//通过access_token获取用户信息
|
...
|
...
|
@@ -421,8 +419,7 @@ class LoginController extends HomeBaseController |
|
|
$res1 = $this->http_get($url1);
|
|
|
$info = json_decode($res1,true);
|
|
|
//查询该微信用户是否存在
|
|
|
var_dump($info);exit;
|
|
|
$where = ['wb_id'=>$info['openid'],'source'=>'微信'];
|
|
|
$where = ['wb_id'=>$info['unionid'],'source'=>'微信'];
|
|
|
$user = $this->findThird($where);
|
|
|
//获取微博id,昵称,头像
|
|
|
$userModel = new UserModel();
|
...
|
...
|
@@ -434,7 +431,7 @@ class LoginController extends HomeBaseController |
|
|
$users['avatar'] = $info['headimgurl'];
|
|
|
$userModel->where(['wb_id'=>$info['openid'],'source'=>'微信'])->update($users);
|
|
|
}else{
|
|
|
$users['wb_id'] = $info['openid'];
|
|
|
$users['wb_id'] = $info['unionid'];
|
|
|
$users['user_nickname'] = $info['nickname'];
|
|
|
$users['avatar'] = $info['headimgurl'];
|
|
|
$users['source'] = '微信';
|
...
|
...
|
@@ -442,6 +439,9 @@ class LoginController extends HomeBaseController |
|
|
$users['create_time'] = time();
|
|
|
$userModel->create($users);
|
|
|
}
|
|
|
$userInfo = $this->findThird($where);
|
|
|
cmf_update_current_user($userInfo);
|
|
|
$this->redirect('/');
|
|
|
}
|
|
|
|
|
|
//第三方微博登录
|
...
|
...
|
|