|
@@ -22,6 +22,9 @@ class LoginController extends HomeBaseController |
|
@@ -22,6 +22,9 @@ class LoginController extends HomeBaseController |
22
|
private $appkey = 737607150;//微博appkey
|
22
|
private $appkey = 737607150;//微博appkey
|
23
|
private $appsecret = 'd80b43a1e74e8ba095590b36a3459480';//微博appsecret
|
23
|
private $appsecret = 'd80b43a1e74e8ba095590b36a3459480';//微博appsecret
|
24
|
private $redirect_uri = 'http://www.xingqiu.cn/portal/login/wb_login';//回调地址
|
24
|
private $redirect_uri = 'http://www.xingqiu.cn/portal/login/wb_login';//回调地址
|
|
|
25
|
+
|
|
|
26
|
+ private $appkey1 = 'wx9cfa880272f186bf';//微信appkey
|
|
|
27
|
+ private $appsecret1 = '11b643393b1e54d6ef5eaa984ba4e545';//微信appsecret
|
25
|
//登录页面
|
28
|
//登录页面
|
26
|
public function login(){
|
29
|
public function login(){
|
27
|
return $this->fetch();
|
30
|
return $this->fetch();
|
|
@@ -348,15 +351,20 @@ class LoginController extends HomeBaseController |
|
@@ -348,15 +351,20 @@ class LoginController extends HomeBaseController |
348
|
|
351
|
|
349
|
//第三方微信登录
|
352
|
//第三方微信登录
|
350
|
public function wx_login(){
|
353
|
public function wx_login(){
|
351
|
- $config = Config::get('wx_login');
|
|
|
352
|
- $app_id = $config['app_id'];
|
|
|
353
|
- $redirect_uri = $config['redirect_uri'];
|
|
|
354
|
- $scope = $config['scope'];
|
|
|
355
|
- $state = md5(uniqid(rand(), TRUE));
|
|
|
356
|
- $url = 'https://open.weixin.qq.com/connect/qrconnect?appid='.$app_id.'&redirect_uri='.$redirect_uri.'&response_type=code&scope='.$scope.'&state='.$state.'#wechat_redirect';
|
354
|
+ $code = $this->request->get('code');
|
|
|
355
|
+ $code = '021HoCq91Re1wP1g5Eo91Vgnq91HoCqd';
|
|
|
356
|
+ $url = 'https://api.weixin.qq.com/sns/oauth2/access_token?appid='.$this->appkey1.'&secret='.$this->appsecret1.'&code='.$code.'&grant_type=authorization_code';
|
357
|
$res = $this->http_get($url);
|
357
|
$res = $this->http_get($url);
|
358
|
- var_dump(11);
|
|
|
359
|
- var_dump($res);exit;
|
358
|
+ $json_arr = json_decode($res,true);
|
|
|
359
|
+// $token = $json_arr['access_token'];
|
|
|
360
|
+ $token = '22_LFufsKgmxT1jCtIuDJ7CLLwAOI7mOPlmNYHRHECuScIwrNZ3-Bmxj8pOjr2NZs7qdzH7iBkPddFtBdyVoBd7zas_gkQhDw3YJgm5iYa6d5w';
|
|
|
361
|
+// $openid = $json_arr['openid'];
|
|
|
362
|
+ $openid = 'oYOYl5hbULoKimG5R8Uk-Paha0d8';
|
|
|
363
|
+ //通过access_token获取用户信息
|
|
|
364
|
+ $url1 = 'https://api.weixin.qq.com/sns/userinfo?access_token='.$token.'&openid='.$openid;
|
|
|
365
|
+ $res1 = $this->http_get($url1);
|
|
|
366
|
+ $json_arr1 = json_decode($res1,true);
|
|
|
367
|
+ var_dump($json_arr1);exit;
|
360
|
}
|
368
|
}
|
361
|
|
369
|
|
362
|
//第三方微博登录
|
370
|
//第三方微博登录
|
|
@@ -391,6 +399,9 @@ class LoginController extends HomeBaseController |
|
@@ -391,6 +399,9 @@ class LoginController extends HomeBaseController |
391
|
$user = $this->findThird($where);
|
399
|
$user = $this->findThird($where);
|
392
|
//获取微博id,昵称,头像
|
400
|
//获取微博id,昵称,头像
|
393
|
$userModel = new UserModel();
|
401
|
$userModel = new UserModel();
|
|
|
402
|
+ $ip = get_client_ip();
|
|
|
403
|
+ $users['last_login_time'] = time();
|
|
|
404
|
+ $users['last_login_ip'] = $ip;
|
394
|
if($user){
|
405
|
if($user){
|
395
|
$users['user_nickname'] = $info['screen_name'];
|
406
|
$users['user_nickname'] = $info['screen_name'];
|
396
|
$users['avatar'] = $info['profile_image_url'];
|
407
|
$users['avatar'] = $info['profile_image_url'];
|
|
@@ -424,8 +435,7 @@ class LoginController extends HomeBaseController |
|
@@ -424,8 +435,7 @@ class LoginController extends HomeBaseController |
424
|
|
435
|
|
425
|
//取消授权
|
436
|
//取消授权
|
426
|
public function wb_cancel(){
|
437
|
public function wb_cancel(){
|
427
|
- echo '取消了';
|
|
|
428
|
-// $this->redirect('/');
|
438
|
+ $this->redirect('/');
|
429
|
}
|
439
|
}
|
430
|
|
440
|
|
431
|
//查询第三方用户是否存在
|
441
|
//查询第三方用户是否存在
|