跟随 php-internal-api-client 修改

This commit is contained in:
George Xie 2018-06-23 11:22:03 +08:00
parent 8e907e99a1
commit df3533f3af
4 changed files with 23 additions and 28 deletions

View File

@ -12,7 +12,7 @@
] ]
}, },
"require": { "require": {
"arch/php-internal-api-client": "^0.6.0" "arch/php-internal-api-client": "^0.6.1"
}, },
"repositories": { "repositories": {
"php-internal-api-client": { "php-internal-api-client": {

10
composer.lock generated
View File

@ -1,18 +1,18 @@
{ {
"_readme": [ "_readme": [
"This file locks the dependencies of your project to a known state", "This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "9120ce1877a91e8f61b9c5e08f2b73b3", "content-hash": "cb24f2da898fb06d105ad5e3b37c9ae5",
"packages": [ "packages": [
{ {
"name": "arch/php-internal-api-client", "name": "arch/php-internal-api-client",
"version": "v0.6", "version": "v0.6.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "git@git.int.haowumc.com:arch/php-internal-api-client.git", "url": "git@git.int.haowumc.com:arch/php-internal-api-client.git",
"reference": "5aaeaa04998ee522133ad9880cee91fa10d47801" "reference": "6c54737d1300c1b4160de3bc476a16a76e450190"
}, },
"require": { "require": {
"guzzlehttp/guzzle": "^6.3", "guzzlehttp/guzzle": "^6.3",
@ -27,7 +27,7 @@
"src/helpers.php" "src/helpers.php"
] ]
}, },
"time": "2018-03-19T09:01:14+00:00" "time": "2018-06-22T12:21:08+00:00"
}, },
{ {
"name": "doctrine/inflector", "name": "doctrine/inflector",

View File

@ -1,22 +1,21 @@
<?php <?php
define('CRM_API_CONFIG', [
'base_uri' => 'http://crm.in.haowumc.com/api/wechat/',
'appid' => 'notification',
'secret' => '123456',
]);
/** /**
* 对企业微信群发送报警信息(需先创建 * 对企业微信群发送报警信息(需先创建
* @param $chat * @param $chat
* @param $text * @param $text
* @return mixed|null * @return mixed|null
*/ */
function chat_text_alert($chat, $text) function chat_text_alert($chat, $text){
{ $client = new \PdInternalApi\Client('crm', CRM_API_CONFIG);
$config = [
'crm' => [
'base_uri' => 'http://crm.in.haowumc.com/api/wechat/',
'appid' => 'notification',
'secret' => '123456',
],
];
$client = (new \PdInternalApi\Client($config))->app('crm');
try { try {
$resp = $client->call('work/text', [ $resp = $client->call('work/text', [
@ -38,15 +37,7 @@ function chat_text_alert($chat, $text)
* @return mixed|null * @return mixed|null
*/ */
function user_text_alert($username, $text){ function user_text_alert($username, $text){
$config = [ $client = new \PdInternalApi\Client('crm', CRM_API_CONFIG);
'crm' => [
'base_uri' => 'http://crm.in.haowumc.com/api/wechat/',
'appid' => 'notification',
'secret' => '123456',
],
];
$client = (new \PdInternalApi\Client($config))->app('crm');
try { try {
$resp = $client->call('work/text', [ $resp = $client->call('work/text', [
@ -59,4 +50,4 @@ function user_text_alert($username, $text){
} }
return $resp; return $resp;
} }

View File

@ -1,8 +1,12 @@
<?php <?php
error_reporting(E_ALL);
ini_set('display_errors', 'stderr');
require_once dirname(__DIR__).'/vendor/autoload.php'; require_once dirname(__DIR__).'/vendor/autoload.php';
$ret = user_text_alert('houxuejie','dfdfdf'); $ret = user_text_alert('xieshi','dfdfdf');
var_dump($ret);
if( $ret['err_code'] == '0' ){ if( $ret['err_code'] == '0' ){
echo "发送成功\n"; echo "发送成功\n";
}else{ }else{