作者 景龙
1 个管道 的构建 通过 耗费 0 秒

调试微信移动登录

@@ -416,7 +416,17 @@ class LoginController extends HomeBaseController @@ -416,7 +416,17 @@ class LoginController extends HomeBaseController
416 $url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='.$this->appkey2.'&secret='.$this->appsecret2; 416 $url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='.$this->appkey2.'&secret='.$this->appsecret2;
417 $res = $this->http_get($url); 417 $res = $this->http_get($url);
418 $json_arr = json_decode($res,true); 418 $json_arr = json_decode($res,true);
419 - var_dump($json_arr);exit; 419 + if(!isset($json_arr['access_token'])&&empty($json_arr['access_token'])){
  420 + //用户取消登录
  421 + $this->redirect('/portal/login/thirdLogin');
  422 + }
  423 + $token = $json_arr['access_token'];
  424 + $openid = 'oYOYl5hbULoKimG5R8Uk-Paha0d8';
  425 + //通过access_token获取用户信息
  426 + $url1 = 'https://api.weixin.qq.com/cgi-bin/user/info?access_token='.$token.'&openid='.$openid.'&lang=zh_CN';
  427 + $res1 = $this->http_get($url1);
  428 + $info = json_decode($res1,true);
  429 + var_dump($info);exit;
420 } 430 }
421 431
422 //第三方微博登录 432 //第三方微博登录