牟新芬 4 years ago
parent
commit
b920bf460f
2 changed files with 6 additions and 13 deletions
  1. 2 9
      app/api/controller/v1/Weixin.php
  2. 4 4
      config/weixin.php

+ 2 - 9
app/api/controller/v1/Weixin.php

@@ -39,15 +39,8 @@ class Weixin extends BaseController
         $code = trim($request->get('code'));
         $code = trim($request->get('code'));
         $weixinA = new weixina;
         $weixinA = new weixina;
         $token = $weixinA->oauth_reuslt($code);
         $token = $weixinA->oauth_reuslt($code);
-        try {
-            $url = 'https://api.weixin.qq.com/sns/userinfo?access_token='. $token['access_token']. '&openid='. $token['openid']. '&lang=zh_CN';
-            $res = json_decode(doRequest($url, [], null, false), true);
-            if (isset($res['errcode']) && $res['errcode'] != 0) {
-                return app('json')->fail($res['errmsg'] ?? $res['msg'] ?? '请求错误');
-            }
-            return $res;
-        } catch (Exception $e) {
-            return app('json')->fail($e->getMessage(), ['file' => $e->getFile(), 'line' => $e->getLine()]);
+        if (!empty($token['access_token'])) {
+            $userInfo = $weixinA->userinfo($token['access_token']);
         }
         }
     }
     }
 
 

+ 4 - 4
config/weixin.php

@@ -10,7 +10,7 @@
 // +----------------------------------------------------------------------
 // +----------------------------------------------------------------------
 
 
 return [
 return [
-  'APPID'       => 'wxa9130b2090dfb130',
-  'APPSECRET'   => 'c816b2725d5071b6be0ab1286e9c8f21',
-  'REDIRECT'    => 'http://api.lipinwawa.com/api/weixin/result'
-];
+  'APPID'       => 'wx21448716e2a0b7df',
+  'APPSECRET'   => '196324da0b037154c00ed3d29827eef7',
+  'REDIRECT'    => 'http://www.boofly.cn/api/weixin/result'
+];