Explorar o código

wesmiler 报恩寺项目提交

wesmiler %!s(int64=4) %!d(string=hai) anos
pai
achega
6f8c054813
Modificáronse 1 ficheiros con 12 adicións e 4 borrados
  1. 12 4
      app/Http/Controllers/Api/v1/IndexController.php

+ 12 - 4
app/Http/Controllers/Api/v1/IndexController.php

@@ -169,13 +169,19 @@ class IndexController extends BaseController
      */
     public function calendar(){
         $apiUrl = env('FOLI_API');
+        $type = request()->get('type', 0);
         if(empty($apiUrl)){
             return message('获取失败', false);
         }
 
-        $content = file_get_contents($apiUrl.'/foli/'.date('Y').'/'.date('m'));
-        $temp = substr($content,strpos($content, '<div class="furborder">'));
-        $temp = substr($temp, 0, strpos($temp, '<div class="calendar mt">'));
+        $content = '';
+        $temp = '';
+        if($type == 0){
+            $content = file_get_contents($apiUrl.'/foli/'.date('Y').'/'.date('m'));
+            $temp = substr($content,strpos($content, '<div class="furborder">'));
+            $temp = substr($temp, 0, strpos($temp, '<div class="calendar mt">'));
+        }
+
 
         // 宜忌
         $content1 = file_get_contents($apiUrl.'/laohuangli/');
@@ -185,8 +191,10 @@ class IndexController extends BaseController
         $yi = isset($yi[1])? $yi[1] : '';
         preg_match("/<td colspan=\"3\">(.*)<\/td>/", $temp1, $ji);
         $ji = isset($ji[1])? $ji[1] : '';
+        preg_match("/<td class>(.*)<\/td>/", $temp1, $yl);
+        $yl = isset($yl[1])? $yl[1] : '';
 
-        return message(MESSAGE_OK, true, ['content'=> $content, 'result'=> $temp,'yj'=> $temp1,'yi'=> $yi,'ji'=> $ji]);
+        return message(MESSAGE_OK, true, ['content'=> $content, 'result'=> $temp,'date'=> date('m月d日'),'yl'=> $yl,'yi'=> $yi,'ji'=> $ji]);
 
     }
 }