当前位置:网站首页>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);}
边栏推荐
- A method that can make large data clustering 2000 times faster
- 领域驱动实践总结(基本理论总结与分析V+架构分析与代码设计+具体应用设计分析)
- 生成树协议STP(Spanning Tree Protocol)
- 广东10个项目入选工信部2021年物联网示范项目名单
- Fragment-hide和show
- 数据产品经理那点事儿 二
- recursive recursive function
- 系统的安全和应用(不会点安全的东西你怎么睡得着?)
- Have you guys encountered this problem?MySQL 2.2 and 2.3-SNAPSHOT are like this, it seems to be
- Code Casual Recording Notes_Dynamic Programming_70 Climbing Stairs
猜你喜欢
AWS Security Fundamentals
Ethernet channel 以太信道
鸿蒙开发从hello world开始
Cloud Migration Practice of Redis
接口自动化测试基础篇
2022-08-09: What does the following go code output?A: No, it will panic; B: Yes, it can run correctly; C: Not sure, see the voting result.package main import (“fmt“ “syn
友邦人寿可观测体系设计与落地
SQL学习(基础)
Existing in the rain of PFAS chemical poses a threat to the safety of drinking water
ABAP 里文件操作涉及到中文字符集的问题和解决方案试读版
随机推荐
ICML 2022 | 基于随机注意力机制的可解释可泛化图学习
Nanodlp v2.2/v3.0 light curing circuit board, connection method of mechanical switch/photoelectric switch/proximity switch and system state level setting
递归递推之计算组合数
R语言使用gt包和gtExtras包优雅地、漂亮地显示表格数据:gtExtras包的gt_highlight_rows函数高亮(highlight)表格中特定的数据行、配置高亮行的特定数据列数据加粗
【JS高级】ES5标准规范之创建子对象以及替换this_10
CodeForces - 834C
Error: Rule can only have one resource source (provided resource and test + include + exclude)
需要被记录的OpenStack相关的命令_自己用
ArcMAP has a problem of -15 and cannot be accessed [Provide your license server administrator with the following information:Err-15]
Fragment-hide and show
交换机的基础知识
Error: Rule can only have one resource source (provided resource and test + include + exclude)
递归递推之递归的函数
Pointer (preliminary solution of C language)
Fragment's show and hide
leetcode 739. Daily Temperatures 每日温度(中等)
Ethernet channel Ethernet channel
ABAP 里文件操作涉及到中文字符集的问题和解决方案试读版
Redis上云迁移实践
recursive recursive function