ソースを参照

feat(打卡):ribao

geek 5 年 前
コミット
5d16bcc7f4
共有2 個のファイルを変更した65 個の追加0 個の削除を含む
  1. 25 0
      application/index/controller/DaKa.php
  2. 40 0
      application/index/service/RiBaoService.php

+ 25 - 0
application/index/controller/DaKa.php

@@ -8,6 +8,7 @@ namespace app\index\controller;
 
 
 use app\index\service\DaKaService;
+use app\index\service\RiBaoService;
 use think\Controller;
 
 class DaKa extends Controller {
@@ -17,4 +18,28 @@ class DaKa extends Controller {
         $service->run();
     }
 
+    public function ribao() {
+
+        $data = [
+            'msgtype' => 'text',
+            'text'    => [
+                'content' => '汇报日报了各位大佬(已写的请忽略)'
+            ]
+        ];
+        $date = date('Y-m-d');
+        var_dump($date);
+        $hm = date('H:i');
+        $w = date('w', strtotime($date));
+        if($w==6 || $w == 0){
+            var_dump($date . '周末,跳过');
+            die();
+        }
+        if ($hm !== '22:00') {
+            var_dump('不是期望时间不提示');
+        }
+        $riBao = new RiBaoService();
+        $riBao->sendMsg($data);
+
+    }
+
 }

+ 40 - 0
application/index/service/RiBaoService.php

@@ -0,0 +1,40 @@
+<?php
+/**
+ * Author: luzheng.liu
+ * Time: 2019-12-18 23:13
+ */
+
+namespace app\index\service;
+
+
+class RiBaoService {
+
+    public function sendMsg($data) {
+        $curl = curl_init();
+
+        curl_setopt_array($curl, [
+            CURLOPT_URL            => "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=abbe9a66-2d91-4430-ac3c-6f5630404042",
+            CURLOPT_RETURNTRANSFER => true,
+            CURLOPT_ENCODING       => "",
+            CURLOPT_MAXREDIRS      => 10,
+            CURLOPT_TIMEOUT        => 30,
+            CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_1_1,
+            CURLOPT_CUSTOMREQUEST  => "POST",
+            CURLOPT_POSTFIELDS     => json_encode($data),
+            CURLOPT_HTTPHEADER     => [
+                "Content-Type: application/json",
+            ],
+        ]);
+
+        $response = curl_exec($curl);
+        $err = curl_error($curl);
+
+        curl_close($curl);
+
+        if ($err) {
+            echo "cURL Error #:" . $err;
+        } else {
+            echo $response;
+        }
+    }
+}