正在显示
1 个修改的文件
包含
0 行增加
和
24 行删除
@@ -39,9 +39,6 @@ class WxloginController extends HomeBaseController | @@ -39,9 +39,6 @@ class WxloginController extends HomeBaseController | ||
39 | $rediUrl = 'http://' .$_SERVER['HTTP_HOST']; | 39 | $rediUrl = 'http://' .$_SERVER['HTTP_HOST']; |
40 | } | 40 | } |
41 | } | 41 | } |
42 | - echo "<pre/>"; | ||
43 | - print_r($rediUrl); | ||
44 | - die; | ||
45 | parent::_initialize(); // TODO: Change the autogenerated stub | 42 | parent::_initialize(); // TODO: Change the autogenerated stub |
46 | if(!Session::get('user.accessToken')){ | 43 | if(!Session::get('user.accessToken')){ |
47 | session('uid',null); | 44 | session('uid',null); |
@@ -86,17 +83,11 @@ class WxloginController extends HomeBaseController | @@ -86,17 +83,11 @@ class WxloginController extends HomeBaseController | ||
86 | */ | 83 | */ |
87 | public function OAuth($redirect_uri){ | 84 | public function OAuth($redirect_uri){ |
88 | if (!Session::get('uid')) { | 85 | if (!Session::get('uid')) { |
89 | - $a['a'] = 1; | ||
90 | - Db::name('Test')->insertGetId($a); | ||
91 | $url = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; | 86 | $url = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; |
92 | $temp_one = explode('code=',$url); | 87 | $temp_one = explode('code=',$url); |
93 | if(!empty($temp_one[1])){ | 88 | if(!empty($temp_one[1])){ |
94 | - $a['a'] = 2; | ||
95 | - Db::name('Test')->insertGetId($a); | ||
96 | $temp_two = explode('&state',$temp_one[1]); | 89 | $temp_two = explode('&state',$temp_one[1]); |
97 | if ($temp_two[0]) { | 90 | if ($temp_two[0]) { |
98 | - $a['a'] = 4; | ||
99 | - Db::name('Test')->insertGetId($a); | ||
100 | //第二步 获取access_token | 91 | //第二步 获取access_token |
101 | $url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=".Config::get('WX_APPID')."&secret=".Config::get('WX_APP_SECRET')."&code=" . $temp_two[0] . "&grant_type=authorization_code"; | 92 | $url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=".Config::get('WX_APPID')."&secret=".Config::get('WX_APP_SECRET')."&code=" . $temp_two[0] . "&grant_type=authorization_code"; |
102 | $resp = file_get_contents($url); | 93 | $resp = file_get_contents($url); |
@@ -105,14 +96,10 @@ class WxloginController extends HomeBaseController | @@ -105,14 +96,10 @@ class WxloginController extends HomeBaseController | ||
105 | Session::set('user.accessToken',$resp_arr['access_token']); | 96 | Session::set('user.accessToken',$resp_arr['access_token']); |
106 | Session::set('user.accessTime',time()); | 97 | Session::set('user.accessTime',time()); |
107 | //第三步 | 98 | //第三步 |
108 | - $a['a'] = 5; | ||
109 | - Db::name('Test')->insertGetId($a); | ||
110 | $refresh_token = $resp_arr['refresh_token']; | 99 | $refresh_token = $resp_arr['refresh_token']; |
111 | $url1 = "https://api.weixin.qq.com/sns/oauth2/refresh_token?appid=".Config::get('WX_APPID')."&grant_type=refresh_token&refresh_token=".$refresh_token; | 100 | $url1 = "https://api.weixin.qq.com/sns/oauth2/refresh_token?appid=".Config::get('WX_APPID')."&grant_type=refresh_token&refresh_token=".$refresh_token; |
112 | $resp1 = file_get_contents($url1); | 101 | $resp1 = file_get_contents($url1); |
113 | $resp_arr1 = json_decode($resp1, true); | 102 | $resp_arr1 = json_decode($resp1, true); |
114 | - $a['a'] = 6; | ||
115 | - Db::name('Test')->insertGetId($a); | ||
116 | //第四步 | 103 | //第四步 |
117 | $access_token = $resp_arr1['access_token']; | 104 | $access_token = $resp_arr1['access_token']; |
118 | $openid = $resp_arr1['openid']; | 105 | $openid = $resp_arr1['openid']; |
@@ -120,8 +107,6 @@ class WxloginController extends HomeBaseController | @@ -120,8 +107,6 @@ class WxloginController extends HomeBaseController | ||
120 | $resp2 = file_get_contents($url2); | 107 | $resp2 = file_get_contents($url2); |
121 | $resp_arr2 = json_decode($resp2, true); | 108 | $resp_arr2 = json_decode($resp2, true); |
122 | $user_headFile['headimgurl'] = $resp_arr2['headimgurl']; | 109 | $user_headFile['headimgurl'] = $resp_arr2['headimgurl']; |
123 | - $a['a'] = 7; | ||
124 | - Db::name('Test')->insertGetId($a); | ||
125 | // 图片路径 | 110 | // 图片路径 |
126 | $save_path['wx_name'] = $resp_arr2['nickname']; | 111 | $save_path['wx_name'] = $resp_arr2['nickname']; |
127 | $save_path['wx_pic'] = $resp_arr2['headimgurl']; | 112 | $save_path['wx_pic'] = $resp_arr2['headimgurl']; |
@@ -129,8 +114,6 @@ class WxloginController extends HomeBaseController | @@ -129,8 +114,6 @@ class WxloginController extends HomeBaseController | ||
129 | $save_path['create_time'] = time(); | 114 | $save_path['create_time'] = time(); |
130 | $save_path['update_time'] = time(); | 115 | $save_path['update_time'] = time(); |
131 | $is_isset = Db::name('Member')->where(array('openid' => $resp_arr2['openid']))->find(); | 116 | $is_isset = Db::name('Member')->where(array('openid' => $resp_arr2['openid']))->find(); |
132 | - $a['a'] = 8; | ||
133 | - Db::name('Test')->insertGetId($a); | ||
134 | if(!$is_isset){ | 117 | if(!$is_isset){ |
135 | $user_id = Db::name('Member')->insertGetId($save_path); | 118 | $user_id = Db::name('Member')->insertGetId($save_path); |
136 | Session::set('uid',$user_id); | 119 | Session::set('uid',$user_id); |
@@ -144,13 +127,6 @@ class WxloginController extends HomeBaseController | @@ -144,13 +127,6 @@ class WxloginController extends HomeBaseController | ||
144 | } | 127 | } |
145 | }else{ | 128 | }else{ |
146 | $url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=".Config::get('WX_APPID')."&redirect_uri=" . $redirect_uri . "&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect"; | 129 | $url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=".Config::get('WX_APPID')."&redirect_uri=" . $redirect_uri . "&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect"; |
147 | - $a['a'] = 3; | ||
148 | - $a['c'] = $url; | ||
149 | - https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxae41c1d85ae2b539&redirect_uri=http://pluralism.w.bronet.cn&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect | ||
150 | - | ||
151 | - $a['e'] = Config::get('WX_APPID'); | ||
152 | - $a['f'] = $redirect_uri; | ||
153 | - Db::name('Test')->insertGetId($a); | ||
154 | Header("Location: $url"); | 130 | Header("Location: $url"); |
155 | exit; | 131 | exit; |
156 | } | 132 | } |
-
请 注册 或 登录 后发表评论