...
|
...
|
@@ -22,6 +22,9 @@ class LoginController extends HomeBaseController |
|
|
private $appkey = 737607150;//微博appkey
|
|
|
private $appsecret = 'd80b43a1e74e8ba095590b36a3459480';//微博appsecret
|
|
|
private $redirect_uri = 'http://www.xingqiu.cn/portal/login/wb_login';//回调地址
|
|
|
|
|
|
private $appkey1 = 'wx9cfa880272f186bf';//微信appkey
|
|
|
private $appsecret1 = '11b643393b1e54d6ef5eaa984ba4e545';//微信appsecret
|
|
|
//登录页面
|
|
|
public function login(){
|
|
|
return $this->fetch();
|
...
|
...
|
@@ -348,15 +351,20 @@ class LoginController extends HomeBaseController |
|
|
|
|
|
//第三方微信登录
|
|
|
public function wx_login(){
|
|
|
$config = Config::get('wx_login');
|
|
|
$app_id = $config['app_id'];
|
|
|
$redirect_uri = $config['redirect_uri'];
|
|
|
$scope = $config['scope'];
|
|
|
$state = md5(uniqid(rand(), TRUE));
|
|
|
$url = 'https://open.weixin.qq.com/connect/qrconnect?appid='.$app_id.'&redirect_uri='.$redirect_uri.'&response_type=code&scope='.$scope.'&state='.$state.'#wechat_redirect';
|
|
|
$code = $this->request->get('code');
|
|
|
$code = '021HoCq91Re1wP1g5Eo91Vgnq91HoCqd';
|
|
|
$url = 'https://api.weixin.qq.com/sns/oauth2/access_token?appid='.$this->appkey1.'&secret='.$this->appsecret1.'&code='.$code.'&grant_type=authorization_code';
|
|
|
$res = $this->http_get($url);
|
|
|
var_dump(11);
|
|
|
var_dump($res);exit;
|
|
|
$json_arr = json_decode($res,true);
|
|
|
// $token = $json_arr['access_token'];
|
|
|
$token = '22_LFufsKgmxT1jCtIuDJ7CLLwAOI7mOPlmNYHRHECuScIwrNZ3-Bmxj8pOjr2NZs7qdzH7iBkPddFtBdyVoBd7zas_gkQhDw3YJgm5iYa6d5w';
|
|
|
// $openid = $json_arr['openid'];
|
|
|
$openid = 'oYOYl5hbULoKimG5R8Uk-Paha0d8';
|
|
|
//通过access_token获取用户信息
|
|
|
$url1 = 'https://api.weixin.qq.com/sns/userinfo?access_token='.$token.'&openid='.$openid;
|
|
|
$res1 = $this->http_get($url1);
|
|
|
$json_arr1 = json_decode($res1,true);
|
|
|
var_dump($json_arr1);exit;
|
|
|
}
|
|
|
|
|
|
//第三方微博登录
|
...
|
...
|
@@ -391,6 +399,9 @@ class LoginController extends HomeBaseController |
|
|
$user = $this->findThird($where);
|
|
|
//获取微博id,昵称,头像
|
|
|
$userModel = new UserModel();
|
|
|
$ip = get_client_ip();
|
|
|
$users['last_login_time'] = time();
|
|
|
$users['last_login_ip'] = $ip;
|
|
|
if($user){
|
|
|
$users['user_nickname'] = $info['screen_name'];
|
|
|
$users['avatar'] = $info['profile_image_url'];
|
...
|
...
|
@@ -424,8 +435,7 @@ class LoginController extends HomeBaseController |
|
|
|
|
|
//取消授权
|
|
|
public function wb_cancel(){
|
|
|
echo '取消了';
|
|
|
// $this->redirect('/');
|
|
|
$this->redirect('/');
|
|
|
}
|
|
|
|
|
|
//查询第三方用户是否存在
|
...
|
...
|
|