mirror of
https://github.com/ProxyPanel/ProxyPanel.git
synced 2026-04-13 07:59:20 +00:00
Fix 企业微信卡片消息中文乱码的问题
This commit is contained in:
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace App\Channels\Components;
|
||||
|
||||
use DOMDocument;
|
||||
use Exception;
|
||||
use Log;
|
||||
|
||||
class WeChat
|
||||
{
|
||||
@@ -39,7 +41,7 @@ class WeChat
|
||||
|
||||
return [0, sha1(implode($array))];
|
||||
} catch (Exception $e) {
|
||||
echo $e->__toString()."\n";
|
||||
Log::critical('企业微信消息推送异常:'.var_export($e->getMessage(), true));
|
||||
|
||||
return [-40003, null]; // ComputeSignatureError
|
||||
}
|
||||
@@ -146,7 +148,7 @@ class WeChat
|
||||
|
||||
return [0, $encrypt];
|
||||
} catch (Exception $e) {
|
||||
echo $e."\n";
|
||||
Log::critical('企业微信消息推送异常:'.var_export($e->getMessage(), true));
|
||||
|
||||
return [-40002, null]; // ParseXmlError
|
||||
}
|
||||
@@ -218,7 +220,7 @@ class Prpcrypt
|
||||
|
||||
return [0, $encrypted];
|
||||
} catch (Exception $e) {
|
||||
echo $e->__toString();
|
||||
Log::critical('企业微信消息推送异常:'.var_export($e->getMessage(), true));
|
||||
|
||||
return [-40006, null]; // EncryptAESError
|
||||
}
|
||||
@@ -230,6 +232,8 @@ class Prpcrypt
|
||||
//解密
|
||||
$decrypted = openssl_decrypt($encrypted, 'AES-256-CBC', $this->key, OPENSSL_ZERO_PADDING, $this->iv);
|
||||
} catch (Exception $e) {
|
||||
Log::critical('企业微信消息推送异常:'.var_export($e->getMessage(), true));
|
||||
|
||||
return [-40007, null]; // DecryptAESError
|
||||
}
|
||||
try {
|
||||
@@ -245,7 +249,8 @@ class Prpcrypt
|
||||
$xml_content = substr($content, 4, $xml_len);
|
||||
$from_receiveId = substr($content, $xml_len + 4);
|
||||
} catch (Exception $e) {
|
||||
echo $e->__toString();
|
||||
// 发送错误
|
||||
Log::critical('企业微信消息推送异常:'.var_export($e->getMessage(), true));
|
||||
|
||||
return [-40008, null]; // IllegalBuffer
|
||||
}
|
||||
|
||||
@@ -68,14 +68,19 @@ class WeChatChannel
|
||||
];
|
||||
} else {
|
||||
$body = [
|
||||
'touser' => '@all',
|
||||
'agentid' => sysConfig('wechat_aid'),
|
||||
'msgtype' => 'text',
|
||||
'text' => ['content' => Markdown::parse($message['content'])->toHtml()],
|
||||
'touser' => '@all',
|
||||
'agentid' => sysConfig('wechat_aid'),
|
||||
'msgtype' => 'textcard',
|
||||
'textcard' => [
|
||||
'title' => $message['title'],
|
||||
'description' => Markdown::parse($message['content'])->toHtml(),
|
||||
'url' => route('admin.index'),
|
||||
'btntxt' => '',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
$response = Http::timeout(15)->post($url, $body);
|
||||
$response = Http::timeout(15)->withBody(json_encode($body, JSON_UNESCAPED_UNICODE), 'application/json; charset=utf-8')->post($url);
|
||||
|
||||
// 发送成功
|
||||
if ($response->ok()) {
|
||||
|
||||
@@ -45,8 +45,7 @@
|
||||
"zbrettonye/hcaptcha": "^1.1",
|
||||
"zbrettonye/no-captcha": "^1.1",
|
||||
"zoujingli/ip2region": "^1.0",
|
||||
"ext-dom": "*",
|
||||
"ext-mcrypt": "*"
|
||||
"ext-dom": "*"
|
||||
},
|
||||
"require-dev": {
|
||||
"arcanedev/laravel-lang": "^8.0",
|
||||
|
||||
469
composer.lock
generated
469
composer.lock
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user