From c9b502ac386b27c08186761e56c9fd3570ca6fcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=80=99=E5=AD=A6=E6=9D=B0?= Date: Tue, 2 Jul 2019 16:41:17 +0800 Subject: [PATCH] no message --- src/functions.php | 442 +++++++++++++++++++++++----------------------- 1 file changed, 221 insertions(+), 221 deletions(-) diff --git a/src/functions.php b/src/functions.php index 323e26d..8a807ed 100644 --- a/src/functions.php +++ b/src/functions.php @@ -1,226 +1,226 @@ env('APP_NAME'), -// 'client' => [ -// 'auth' => [ -// 'base_uri' => 'http://auth.in.haowumc.com', -// ], -// ], -//]); -// -///** -// * 对企业微信群发送报警信息(需先创建 -// * -// * @param $chat -// * @param $text -// * -// * @return mixed|null -// */ -// -//function chat_text_alert ($chat, $text) -//{ -// if (env('APP_ENV') == 'local') { -// return true; -// } -// $base_client = new \JsonRpc\Client(RPC_CONFIG); -// $client = $base_client->endpoint('auth'); -// -// try { -// $resp = $client->call('notify.text', [ -// ['chat' => $chat], -// $text, -// ]); -// } catch (Exception $ex) { -// var_dump($ex->getMessage()); -// return null; -// } -// -// return $resp; -//} -// -///** -// * 对单个或多个用户发送报警或通知信息,多个用户id使用 | 隔开 -// * -// * @param $text -// * -// * @return mixed|null -// */ -//function user_text_alert ($username, $text) -//{ -// if (env('APP_ENV') == 'local') { -// return true; -// } -// $base_client = new \JsonRpc\Client(RPC_CONFIG); -// $client = $base_client->endpoint('auth'); -// -// $username = explode('|', $username); -// try { -// $res = $client->call('notify.text', [ -// ['user' => $username], -// $text, -// ]); -// } catch (Exception $ex) { -// var_dump($ex->getMessage()); -// return null; -// } -// -// return $res; -//} -// -///** -// * 对微信群发送文本卡片 -// * -// * @param $chat -// * @param $title -// * @param $desc -// * @param $button -// * @param $url -// * -// * @return mixed|null -// */ -//function chat_card_alert ($chat, $title, $desc, $button, $url) -//{ -// if (env('APP_ENV') == 'local') { -// return true; -// } -// -// $base_client = new \JsonRpc\Client(RPC_CONFIG); -// $client = $base_client->endpoint('auth'); -// -// try { -// $resp = $client->call('notify.card', [ -// ['chat' => $chat], -// $title, -// $desc, -// $button, -// $url, -// ]); -// } catch (Exception $ex) { -// var_dump($ex->getMessage()); -// return null; -// } -// -// return $resp; -//} -// -///** -// * 对单个或多个用户发送文本卡片,多个用户id使用 | 隔开 -// * -// * @param $username -// * @param $title -// * @param $desc -// * @param $button -// * @param $url -// * -// * @return mixed|null -// */ -//function user_card_alert ($username, $title, $desc, $button, $url) -//{ -// if (env('APP_ENV') == 'local') { -// return true; -// } -// -// $base_client = new \JsonRpc\Client(RPC_CONFIG); -// $client = $base_client->endpoint('auth'); -// -// $username = explode('|', $username); -// try { -// $resp = $client->call('notify.card', [ -// ['user' => $username], -// $title, -// $desc, -// $button, -// $url, -// ]); -// } catch (Exception $ex) { -// var_dump($ex->getMessage()); -// return null; -// } -// -// return $resp; -//} -// -///** -// * 对单个或多个用户发送文本卡片,多个用户id使用 | 隔开 -// * -// * @param $username -// * @param $appid //小程序的appid -// * @param $title //标题 -// * @param $page //小程序页面路径 -// * @param $desc //描述 -// * @param $items //消息内容键值对,最多允许10个item -// * @param $emphasisFirstItem //是否放大第一个content_item -// * -// * @return mixed|null -// */ -//function user_mp_alert ($username, $appid, $title, $page = null, $desc = null, $items = null, $emphasisFirstItem = null) -//{ -// if (env('APP_ENV') == 'local') { -// return true; -// } -// -// $base_client = new \JsonRpc\Client(RPC_CONFIG); -// $client = $base_client->endpoint('auth'); -// -// $username = explode('|', $username); -// try { -// $resp = $client->call('notify.mp', [ -// ['user' => $username], -// $appid, -// $title, -// $page, -// $desc, -// $items, -// $emphasisFirstItem -// ]); -// } catch (Exception $ex) { -// var_dump($ex->getMessage()); -// return null; -// } -// -// return $resp; -//} -// -///** -// * 对单个或多个用户发送文本卡片,多个用户id使用 | 隔开 -// * -// * @param $username -// * @param $appid //小程序的appid -// * @param $title //标题 -// * @param $page //小程序页面路径 -// * @param $desc //描述 -// * @param $items //消息内容键值对,最多允许10个item -// * @param $emphasisFirstItem //是否放大第一个content_item -// * -// * @return mixed|null -// */ -//function tag_mp_alert ($tag, $appid, $title, $page = null, $desc = null, $items = null, $emphasisFirstItem = null) -//{ -// if (env('APP_ENV') == 'local') { -// return true; -// } -// -// $base_client = new \JsonRpc\Client(RPC_CONFIG); -// $client = $base_client->endpoint('auth'); -// -// try { -// $resp = $client->call('notify.mp', [ -// ['tag' => $tag], -// $appid, -// $title, -// $page, -// $desc, -// $items, -// $emphasisFirstItem -// ]); -// } catch (Exception $ex) { -// var_dump($ex->getMessage()); -// return null; -// } -// -// return $resp; -//} +define('RPC_CONFIG', [ + 'app' => env('APP_NAME'), + 'client' => [ + 'auth' => [ + 'base_uri' => 'http://auth.in.haowumc.com', + ], + ], +]); + +/** + * 对企业微信群发送报警信息(需先创建 + * + * @param $chat + * @param $text + * + * @return mixed|null + */ + +function chat_text_alert ($chat, $text) +{ + if (env('APP_ENV') == 'local') { + return true; + } + $base_client = new \JsonRpc\Client(RPC_CONFIG); + $client = $base_client->endpoint('auth'); + + try { + $resp = $client->call('notify.text', [ + ['chat' => $chat], + $text, + ]); + } catch (Exception $ex) { + var_dump($ex->getMessage()); + return null; + } + + return $resp; +} + +/** + * 对单个或多个用户发送报警或通知信息,多个用户id使用 | 隔开 + * + * @param $text + * + * @return mixed|null + */ +function user_text_alert ($username, $text) +{ + if (env('APP_ENV') == 'local') { + return true; + } + $base_client = new \JsonRpc\Client(RPC_CONFIG); + $client = $base_client->endpoint('auth'); + + $username = explode('|', $username); + try { + $res = $client->call('notify.text', [ + ['user' => $username], + $text, + ]); + } catch (Exception $ex) { + var_dump($ex->getMessage()); + return null; + } + + return $res; +} + +/** + * 对微信群发送文本卡片 + * + * @param $chat + * @param $title + * @param $desc + * @param $button + * @param $url + * + * @return mixed|null + */ +function chat_card_alert ($chat, $title, $desc, $button, $url) +{ + if (env('APP_ENV') == 'local') { + return true; + } + + $base_client = new \JsonRpc\Client(RPC_CONFIG); + $client = $base_client->endpoint('auth'); + + try { + $resp = $client->call('notify.card', [ + ['chat' => $chat], + $title, + $desc, + $button, + $url, + ]); + } catch (Exception $ex) { + var_dump($ex->getMessage()); + return null; + } + + return $resp; +} + +/** + * 对单个或多个用户发送文本卡片,多个用户id使用 | 隔开 + * + * @param $username + * @param $title + * @param $desc + * @param $button + * @param $url + * + * @return mixed|null + */ +function user_card_alert ($username, $title, $desc, $button, $url) +{ + if (env('APP_ENV') == 'local') { + return true; + } + + $base_client = new \JsonRpc\Client(RPC_CONFIG); + $client = $base_client->endpoint('auth'); + + $username = explode('|', $username); + try { + $resp = $client->call('notify.card', [ + ['user' => $username], + $title, + $desc, + $button, + $url, + ]); + } catch (Exception $ex) { + var_dump($ex->getMessage()); + return null; + } + + return $resp; +} + +/** + * 对单个或多个用户发送文本卡片,多个用户id使用 | 隔开 + * + * @param $username + * @param $appid //小程序的appid + * @param $title //标题 + * @param $page //小程序页面路径 + * @param $desc //描述 + * @param $items //消息内容键值对,最多允许10个item + * @param $emphasisFirstItem //是否放大第一个content_item + * + * @return mixed|null + */ +function user_mp_alert ($username, $appid, $title, $page = null, $desc = null, $items = null, $emphasisFirstItem = null) +{ + if (env('APP_ENV') == 'local') { + return true; + } + + $base_client = new \JsonRpc\Client(RPC_CONFIG); + $client = $base_client->endpoint('auth'); + + $username = explode('|', $username); + try { + $resp = $client->call('notify.mp', [ + ['user' => $username], + $appid, + $title, + $page, + $desc, + $items, + $emphasisFirstItem + ]); + } catch (Exception $ex) { + var_dump($ex->getMessage()); + return null; + } + + return $resp; +} + +/** + * 对单个或多个用户发送文本卡片,多个用户id使用 | 隔开 + * + * @param $username + * @param $appid //小程序的appid + * @param $title //标题 + * @param $page //小程序页面路径 + * @param $desc //描述 + * @param $items //消息内容键值对,最多允许10个item + * @param $emphasisFirstItem //是否放大第一个content_item + * + * @return mixed|null + */ +function tag_mp_alert ($tag, $appid, $title, $page = null, $desc = null, $items = null, $emphasisFirstItem = null) +{ + if (env('APP_ENV') == 'local') { + return true; + } + + $base_client = new \JsonRpc\Client(RPC_CONFIG); + $client = $base_client->endpoint('auth'); + + try { + $resp = $client->call('notify.mp', [ + ['tag' => $tag], + $appid, + $title, + $page, + $desc, + $items, + $emphasisFirstItem + ]); + } catch (Exception $ex) { + var_dump($ex->getMessage()); + return null; + } + + return $resp; +} /**