DingService.php
1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
/**
* @author:wlj
* @date: 2022/8/10 15:02
*/
namespace App\Services;
use App\Enums\Common\RedisKey;
use App\Services\BaseService;
use App\Traits\RedisTrait;
use App\Utils\HttpUtils;
class DingService
{
use RedisTrait;
const LINK = 'https://oapi.dingtalk.com/robot/send?access_token=2cdba958f11f24f961f13aba2d1acbcd60ed64c998a184492cc63814696e34e1';
const INFO = 'INFO';
const ERROR = 'ERROR';
const WARNNING = 'WARNNING';
const OTHER = 'OTHER';
/**
* @remark :钉钉发送错误信息
* @name :handle
* @author :lyh
* @method :post
* @time :2025/3/19 18:03
*/
public function handle(array $body)
{
$msgKey = mb_substr($body['msg'], 50);
if (!$this->getData(RedisKey::DING_MSG . $msgKey)) {
$arr = [
'msgtype' => 'text',
'text' => [
'content' => $body['keyword'] . PHP_EOL . $body['msg']
],
'at' => [
'atMobiles' => [],
'atUserIds' => [],
'isAtAll' => $body['isAtAll'],
]
];
$re = json_decode(HttpUtils::post(self::LINK, $arr), true);
$this->setData(RedisKey::DING_MSG . $msgKey, true, 60);
return $re['errcode'] ?? 0;
}
return 0;
}
}