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

调试手机微信登录

... ... @@ -405,17 +405,20 @@ class LoginController extends HomeBaseController
//第三方微信移动端网页登录
public function wx_login_mobile(){
$url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='.$this->appkey2.'&secret='.$this->appsecret2;
$code = $this->request->get('code');
var_dump($code);exit;
$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);
$json_arr = json_decode($res,true);
if(!isset($json_arr['access_token'])&&empty($json_arr['access_token'])){
//用户取消登录
$this->redirect('/portal/login/thirdLogin');
}
$token = $json_arr['access_token'];
$openid = 'oYOYl5hbULoKimG5R8Uk-Paha0d8';
$openid = $json_arr['openid'];
//通过access_token获取用户信息
$url1 = 'https://api.weixin.qq.com/cgi-bin/user/info?access_token='.$token.'&openid='.$openid.'&lang=zh_CN';
$url1 = 'https://api.weixin.qq.com/sns/userinfo?access_token='.$token.'&openid='.$openid;
$res1 = $this->http_get($url1);
$info = json_decode($res1,true);
var_dump($info);exit;
... ...
... ... @@ -43,14 +43,16 @@
</div>
<div class="index_tenth_seconds">
<div class="index_tenth_second">
<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">
<div class="index_tenth_second_one">
<div class="index_tenth_second_img" id="wx_login">
<div class="index_tenth_second_img">
<img src="__TMPL__/public/assets/images/cicon_71@2x.png" alt="" />
</div>
<div class="index_tenth_second_title">
微信登录
</div>
</div>
</a>
<form action="https://api.weibo.com/oauth2/authorize" method="POST" id="wb_form">
<div class="index_tenth_second_one">
... ...
... ... @@ -28,8 +28,11 @@ class HomeBaseController extends BaseController
public $appkey1 = 'wx9cfa880272f186bf';//微信开放平台appkey
public $appsecret1 = '11b643393b1e54d6ef5eaa984ba4e545';//微信开放平台appsecret
public $appkey2 = 'wx0bd7bc2aa0f332d6';//微信公众号appkey
public $appsecret2 = 'b62e49f48f48de7b7fff2ea0af3939de';//微信公众号appsecret
public $appkey2 = 'wx0bd7bc2aa0f332d6';//微信公众订阅号appkey
public $appsecret2 = 'b62e49f48f48de7b7fff2ea0af3939de';//微信公众订阅号appsecret
public $appkey3 = 'wx3f1a38ee1e74f2bc';//微信公众服务号appkey
public $appsecret3 = '87f9c080450979db7d6a5e296529b577';//微信公众服务号appsecret
protected function initialize()
{
... ...