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

调试手机微信登录

@@ -405,17 +405,20 @@ class LoginController extends HomeBaseController @@ -405,17 +405,20 @@ class LoginController extends HomeBaseController
405 405
406 //第三方微信移动端网页登录 406 //第三方微信移动端网页登录
407 public function wx_login_mobile(){ 407 public function wx_login_mobile(){
408 - $url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='.$this->appkey2.'&secret='.$this->appsecret2; 408 + $code = $this->request->get('code');
  409 + var_dump($code);exit;
  410 + $url = 'https://api.weixin.qq.com/sns/oauth2/access_token?appid='.$this->appkey1.'&secret='.$this->appsecret1.'&code='.$code.'&grant_type=authorization_code';
409 $res = $this->http_get($url); 411 $res = $this->http_get($url);
410 $json_arr = json_decode($res,true); 412 $json_arr = json_decode($res,true);
  413 +
411 if(!isset($json_arr['access_token'])&&empty($json_arr['access_token'])){ 414 if(!isset($json_arr['access_token'])&&empty($json_arr['access_token'])){
412 //用户取消登录 415 //用户取消登录
413 $this->redirect('/portal/login/thirdLogin'); 416 $this->redirect('/portal/login/thirdLogin');
414 } 417 }
415 $token = $json_arr['access_token']; 418 $token = $json_arr['access_token'];
416 - $openid = 'oYOYl5hbULoKimG5R8Uk-Paha0d8'; 419 + $openid = $json_arr['openid'];
417 //通过access_token获取用户信息 420 //通过access_token获取用户信息
418 - $url1 = 'https://api.weixin.qq.com/cgi-bin/user/info?access_token='.$token.'&openid='.$openid.'&lang=zh_CN'; 421 + $url1 = 'https://api.weixin.qq.com/sns/userinfo?access_token='.$token.'&openid='.$openid;
419 $res1 = $this->http_get($url1); 422 $res1 = $this->http_get($url1);
420 $info = json_decode($res1,true); 423 $info = json_decode($res1,true);
421 var_dump($info);exit; 424 var_dump($info);exit;
@@ -43,14 +43,16 @@ @@ -43,14 +43,16 @@
43 </div> 43 </div>
44 <div class="index_tenth_seconds"> 44 <div class="index_tenth_seconds">
45 <div class="index_tenth_second"> 45 <div class="index_tenth_second">
46 - <div class="index_tenth_second_one">  
47 - <div class="index_tenth_second_img" id="wx_login">  
48 - <img src="__TMPL__/public/assets/images/cicon_71@2x.png" alt="" />  
49 - </div>  
50 - <div class="index_tenth_second_title">  
51 - 微信登录 46 + <a href="https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx3f1a38ee1e74f2bc&redirect_uri=http://www.starplanet.cn/portal/login/wx_login_mobile&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect">
  47 + <div class="index_tenth_second_one">
  48 + <div class="index_tenth_second_img">
  49 + <img src="__TMPL__/public/assets/images/cicon_71@2x.png" alt="" />
  50 + </div>
  51 + <div class="index_tenth_second_title">
  52 + 微信登录
  53 + </div>
52 </div> 54 </div>
53 - </div> 55 + </a>
54 56
55 <form action="https://api.weibo.com/oauth2/authorize" method="POST" id="wb_form"> 57 <form action="https://api.weibo.com/oauth2/authorize" method="POST" id="wb_form">
56 <div class="index_tenth_second_one"> 58 <div class="index_tenth_second_one">
@@ -28,8 +28,11 @@ class HomeBaseController extends BaseController @@ -28,8 +28,11 @@ class HomeBaseController extends BaseController
28 public $appkey1 = 'wx9cfa880272f186bf';//微信开放平台appkey 28 public $appkey1 = 'wx9cfa880272f186bf';//微信开放平台appkey
29 public $appsecret1 = '11b643393b1e54d6ef5eaa984ba4e545';//微信开放平台appsecret 29 public $appsecret1 = '11b643393b1e54d6ef5eaa984ba4e545';//微信开放平台appsecret
30 30
31 - public $appkey2 = 'wx0bd7bc2aa0f332d6';//微信公众号appkey  
32 - public $appsecret2 = 'b62e49f48f48de7b7fff2ea0af3939de';//微信公众号appsecret 31 + public $appkey2 = 'wx0bd7bc2aa0f332d6';//微信公众订阅号appkey
  32 + public $appsecret2 = 'b62e49f48f48de7b7fff2ea0af3939de';//微信公众订阅号appsecret
  33 +
  34 + public $appkey3 = 'wx3f1a38ee1e74f2bc';//微信公众服务号appkey
  35 + public $appsecret3 = '87f9c080450979db7d6a5e296529b577';//微信公众服务号appsecret
33 36
34 protected function initialize() 37 protected function initialize()
35 { 38 {