init
This commit is contained in:
commit
883593849d
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
.idea
|
||||
vendor
|
26
composer.json
Normal file
26
composer.json
Normal file
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"name": "arch/notification",
|
||||
"authors": [
|
||||
{
|
||||
"name": "候学杰",
|
||||
"email": "houxuejie@haowumc.com"
|
||||
}
|
||||
],
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Arch\\Notification\\": "src/Notification"
|
||||
},
|
||||
"files": [
|
||||
"src/functions.php"
|
||||
]
|
||||
},
|
||||
"require": {
|
||||
"arch/php-internal-api-client": "^0.6.0"
|
||||
},
|
||||
"repositories": {
|
||||
"php-internal-api-client": {
|
||||
"type": "vcs",
|
||||
"url": "git@git.int.haowumc.com:arch/php-internal-api-client.git"
|
||||
}
|
||||
}
|
||||
}
|
1214
composer.lock
generated
Normal file
1214
composer.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
62
src/functions.php
Normal file
62
src/functions.php
Normal file
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* 对企业微信群发送报警信息(需先创建
|
||||
* @param $chat
|
||||
* @param $text
|
||||
* @return mixed|null
|
||||
*/
|
||||
function chat_text_alert($chat, $text)
|
||||
{
|
||||
$config = [
|
||||
'crm' => [
|
||||
'base_uri' => 'http://crm.lo.haowumc.com/api/wechat/',
|
||||
'appid' => 'notification',
|
||||
'secret' => '123456',
|
||||
],
|
||||
];
|
||||
|
||||
$client = (new \PdInternalApi\Client($config))->app('crm');
|
||||
|
||||
try {
|
||||
$resp = $client->call('work/text', [
|
||||
'chat_id' => $chat,
|
||||
'text' => $text,
|
||||
]);
|
||||
} catch (Exception $ex) {
|
||||
var_dump($ex->getMessage());
|
||||
return null;
|
||||
}
|
||||
|
||||
return $resp;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对单个或多个用户发送报警或通知信息,多个用户id使用 | 隔开
|
||||
* @param $username
|
||||
* @param $text
|
||||
* @return mixed|null
|
||||
*/
|
||||
function user_text_alert($username, $text){
|
||||
$config = [
|
||||
'crm' => [
|
||||
'base_uri' => 'http://crm.lo.haowumc.com/api/wechat/',
|
||||
'appid' => 'notification',
|
||||
'secret' => '123456',
|
||||
],
|
||||
];
|
||||
|
||||
$client = (new \PdInternalApi\Client($config))->app('crm');
|
||||
|
||||
try {
|
||||
$resp = $client->call('work/text', [
|
||||
'username' => $username,
|
||||
'text' => $text,
|
||||
]);
|
||||
} catch (Exception $ex) {
|
||||
var_dump($ex->getMessage());
|
||||
return null;
|
||||
}
|
||||
|
||||
return $resp;
|
||||
}
|
11
tests/text.php
Normal file
11
tests/text.php
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
require_once dirname(__DIR__).'/vendor/autoload.php';
|
||||
|
||||
$ret = notify('houxuejie','dfdfdf');
|
||||
if( $ret['err_code'] == '0' ){
|
||||
echo "发送成功\n";
|
||||
}else{
|
||||
echo "发送失败,原因{$ret['err_msg']}\n";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user