Commit 4b399344 by xmy

feat:构建通知

parent b1191262
...@@ -16,30 +16,32 @@ $basePath = dirname(__DIR__, 3); ...@@ -16,30 +16,32 @@ $basePath = dirname(__DIR__, 3);
* ]; * ];
*/ */
function buildNotice($msg) if (!function_exists('buildNotice')){
{ function buildNotice($msg)
$jsonStr = json_encode([ {
'msgtype' => 'text', $jsonStr = json_encode([
'text' => [ 'msgtype' => 'text',
'content' => $msg 'text' => [
] 'content' => $msg
]); ]
$url = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=97225115-5aa1-47e9-a029-04d0c25abb47"; ]);
$ch = curl_init(); $url = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=97225115-5aa1-47e9-a029-04d0c25abb47";
curl_setopt($ch, CURLOPT_POST, 1); $ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonStr); curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonStr);
curl_setopt($ch, CURLOPT_HTTPHEADER, array( curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
'Content-Type: application/json; charset=utf-8', curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Length: ' . strlen($jsonStr) 'Content-Type: application/json; charset=utf-8',
) 'Content-Length: ' . strlen($jsonStr)
); )
$response = curl_exec($ch); );
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); $response = curl_exec($ch);
curl_close($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
return array($httpCode, $response); return array($httpCode, $response);
}
} }
try { try {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment