cqp 2 месяцев назад
Родитель
Сommit
fb1a2fc65f
2 измененных файлов с 22 добавлено и 0 удалено
  1. 10 0
      app/Http/Controllers/Api/WeixinController.php
  2. 12 0
      app/Service/Weixin/WeixinService.php

+ 10 - 0
app/Http/Controllers/Api/WeixinController.php

@@ -92,4 +92,14 @@ class WeixinController extends BaseController
             return $this->json_return(201, $data);
         }
     }
+
+    public function test(Request $request){
+        $service = new WeixinService();
+        list($status,$data) = $service->test($request->all());
+        if ($status) {
+            return $this->json_return(200, '', $data);
+        } else {
+            return $this->json_return(201, $data);
+        }
+    }
 }

+ 12 - 0
app/Service/Weixin/WeixinService.php

@@ -165,4 +165,16 @@ class WeixinService extends Service
 //        return [false,json_encode($res)];
 //
 //    }
+
+    public function test($data){
+        list($status, $token) = $this->getTokenSTABLE();
+        if (!$status) return [false, $token];
+        $url = "https://api.weixin.qq.com/cgi-bin/menu/get?access_token=" . $token;
+        $res = $this->curlOpen($url);
+        $res = json_decode($res, true);
+        if (isset($res['errcode']) && $res['errcode'] != 0) return [false, $res['errmsg']];
+        if (isset($res['errcode']) && $res['errcode'] === 0) return [true, ''];
+        return [false, json_encode($res)];
+        dd($res);
+    }
 }