当前位置:网站首页>laravel throws the error to Dingding
laravel throws the error to Dingding
2022-08-10 13:53:00 【nerd peak】
Reference API: Message Types Supported by Internal Robots - Dingding Open Platform
Project error thrown: app/Exceptions/Handler.php
1. Preparations
Dingding creates a group, and then intelligent group assistant
2. Add a custom robot
3. Set security settings and record Webhook
4. Code: [package as needed]
public function report(Exception $exception){if ($this->shouldReport($exception)) {$msg = $exception->getMessage();$url = 'webhook';// The first step is to use the timestamp+"\n"+ key as the signature string, use the HmacSHA256 algorithm to calculate the signature, then perform Base64 encode, and finally urlEncode the signature parameters to get the final signature (UTF-8 required)character set).$time = time() * 1000;//Millisecond timestamp, for convenience, I directly set the time * 1000$secret = 'Secret key';$sign = hash_hmac('sha256', $time . "\n" . $secret, $secret, true);$sign = base64_encode($sign);$sign = urlencode($sign);$msg = ['msgtype' => 'text',//This is the file sending type, which can be adjusted according to needs'text' => [ // Send the information received by the DingTalk group'content' => ['url' => Request::url(),'params' => Request::getRequestUri(),'msg' => $msg],],];$url = "{$url}×tamp={$time}&sign={$sign}";$curl = curl_init();curl_setopt($curl, CURLOPT_URL, $url);curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);curl_setopt($curl, CURLOPT_POST, 1);curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($msg));curl_setopt($curl, CURLOPT_HEADER, 0);curl_setopt($curl, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);$res = curl_exec($curl);curl_close($curl);// Log::info('Exception Happen', [// 'url' => Request::url(),// 'params' => Request::getRequestUri(),// ]);}parent::report($exception);}
边栏推荐
- The basic components of Loudi plant cell laboratory construction
- The recursive recursive Fighting_ silver study ah but level 4
- M²BEV: Multi-Camera Joint 3D Detection and Segmentation with Unified Bird’s-Eye View Representation
- AWS 安全基础知识
- 2022-08-09:以下go语言代码输出什么?A:否,会 panic;B:是,能正确运行;C:不清楚,看投票结果。 package main import ( “fmt“ “syn
- Circle 创始人回应美财政部禁止 Tornado :隐私与安全之间关系紧张
- AWS Security Fundamentals
- 高数_证明_曲率公式
- 代码随想录笔记_动态规划_70爬楼梯
- 【ECCV 2022|百万奖金】PSG大赛:追求“最全面”的场景理解
猜你喜欢
ABAP 里文件操作涉及到中文字符集的问题和解决方案试读版
MySQL interview questions
AWS Security Fundamentals
WebView的优化与常见问题解决方案
3DS MAX batch export file script MAXScript with interface
Efficient and Robust 2D-to-BEV Representation Learning via Geometry-guided Kernel Transformer Paper Notes
Existing in the rain of PFAS chemical poses a threat to the safety of drinking water
IT小白怎么系统的php学习
Error: Rule can only have one resource source (provided resource and test + include + exclude)
Code Casual Recording Notes_Dynamic Programming_70 Climbing Stairs
随机推荐
网络安全——XSS之被我们忽视的Cookie
Ethernet channel Ethernet channel
什么?你还不会JVM调优?
Cloud Migration Practice of Redis
Pointer (preliminary solution of C language)
ABAP file operations involved in the Chinese character set of problems and solutions for trying to read
文件系统设计
Network Saboteur
M²BEV: Multi-Camera Joint 3D Detection and Segmentation with Unified Bird’s-Eye View Representation
CodeForces - 834C
X5WebView使用
每个月工资表在数据库如何存储?求一个设计思路
指针(C语言初解)
进程和计划任务管理
实现一个深克隆
Wirshark common operations and tcp three-way handshake process example analysis
The recursive recursive Fighting_ silver study ah but level 4
the height of the landscape
ICML 2022 | 基于随机注意力机制的可解释可泛化图学习
YTU 2295: KMP模式匹配 一(串)