- 优化报错,支持微信通知

v6
Chaim 4 years ago
parent 3bfc58f252
commit 810cf5a798

@ -85,6 +85,13 @@ return [
// 钉钉
'dingtalk' => [
'access_token' => ''
],
// 微信
'wechat' => [
// 通知微信
'openid' => '',
// 网站名称
'node' => ''
]
]
];

@ -16,7 +16,9 @@
namespace DtApp\ThinkLibrary\exception;
use DtApp\ThinkLibrary\service\curl\HttpService;
use DtApp\ThinkLibrary\service\DingTalkService;
use DtApp\ThinkLibrary\service\SystemService;
use think\exception\Handle;
use think\exception\HttpException;
use think\exception\ValidateException;
@ -69,6 +71,21 @@ class ThinkException extends Handle
->accessToken($access_token)
->text($msg);
}
if (!empty($nt) && $nt == 'wechat') {
$openid = config('dtapp.exception.wechat.openid', '');
if (!empty($access_token)) return HttpService::instance()
->url("https://api.dtapp.net/v1/wechatmp/tmplmsgWebError/openid/{$openid}")
->post()
->data([
'domain' => request()->domain(),
'url' => request()->url(),
'node' => config('dtapp.exception.wechat.node', ''),
'info' => '服务器IP为' . SystemService::instance()
->linuxIp(),
'error' => base64_encode($msg)
])
->toArray();
}
return true;
}
}

@ -136,4 +136,18 @@ class SystemService extends Service
}
}
}
/**
* 获取Linux服务器IP
* @return string
*/
public function linuxIp()
{
try {
$ip_cmd = "ifconfig eth0 | sed -n '/inet addr/p' | awk '{print $2}' | awk -F ':' '{print $2}'";
return trim(exec($ip_cmd));
} catch (\Exception $e) {
return "0.0.0.0";
}
}
}

Loading…
Cancel
Save