Feishu.php 2.7 KB
<?php

namespace jiaoyin;

class Feishu
{
    const user_liquid = 'gd1d6b34';
    const user_jiaoyin = 'efdgdecb';
    const user_small = 'db9d9g4d';
    const user_linghu = '6ac9fb35';
    const user_tanli = 'f16c2bd7';
    const user_007 = '9de6cgf3';
    //风控处置群
    const url_risk = 'https://open.feishu.cn/open-apis/bot/v2/hook/7509c731-a1ab-4e2f-b781-9082a26fd11d';
    //零容忍
    const url_error = 'https://open.feishu.cn/open-apis/bot/v2/hook/a344e313-4d5d-4aa4-912b-dda37b2e3ee8';
    //零忽略
    const url_warning = 'https://open.feishu.cn/open-apis/bot/v2/hook/01c53b94-378a-45a3-abed-415f84f57f4a';
    //软件异常报警
    const url_warning_soft = 'https://open.feishu.cn/open-apis/bot/v2/hook/d48c2e4a-0ef9-4684-88d4-e62d878fdaca';
    //测试频道
    const url_test = 'https://open.feishu.cn/open-apis/bot/v2/hook/34a9f127-3838-43fc-bc35-6f5e4e96bf6d';
    //交易与跟单业务沟通
    const url_follow = 'https://open.feishu.cn/open-apis/bot/v2/hook/f30bbb72-091c-499d-a577-43c45dceb158';
    //A01-交易策略研发沟通
    const url_strategy = 'https://open.feishu.cn/open-apis/bot/v2/hook/53444f37-cfec-420c-a4e6-2f415b908dee';
    //网格策略运营群
    const url_grid = 'https://open.feishu.cn/open-apis/bot/v2/hook/19471aa1-f926-46d7-a1d5-a367d1449092';
    //量化机会通知群
    const url_quant_chance = 'https://open.feishu.cn/open-apis/bot/v2/hook/b590bbd4-6a0a-4328-bf28-9fc15677643e';
    static public function notice(string $content, string $channel_url, array $users = [])
    {
        $userXml = '';
        foreach ($users as $user) {
            $userXml .= "<at user_id='" . $user . "'></at>";
        }
        $content = [
            'msg_type' => "text",
            'content' => [
                'text' => $content . $userXml
            ]
        ];
        $con = json_encode($content);
        return self::send_post_json($channel_url, $con);
    }
    static public function send_post_json($url, $jsonStr)
    {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonStr);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt(
            $ch,
            CURLOPT_HTTPHEADER,
            array(
                'Content-Type: application/json; charset=utf-8',
                'Content-Length: ' . strlen($jsonStr)
            )
        );
        $response = curl_exec($ch);
        $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        curl_close($ch);
        return array($httpCode, $response);
    }
}