-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
caicheng
committed
Dec 10, 2018
0 parents
commit ac0428f
Showing
6 changed files
with
140 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.idea/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"name": "dishcheng/dd_notice", | ||
"description": "网易云短信包", | ||
"keywords": [ | ||
"叮叮", | ||
"推送", | ||
"通知", | ||
"机器人" | ||
], | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "caicheng", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"require": { | ||
"php": ">=7.0.0", | ||
"laravel/framework": ">=5.5" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"DishCheng\\DdNotice\\": "src/" | ||
} | ||
}, | ||
"extra": { | ||
"laravel": { | ||
"providers": [ | ||
"DishCheng\\DdNotice\\DdNoticeProvider" | ||
], | ||
"aliases": { | ||
"DdNotice": "DishCheng\\DdNotice\\DdNotice" | ||
} | ||
} | ||
}, | ||
"minimum-stability": "dev" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: caicheng | ||
* Date: 2018-12-10 | ||
* Time: 11:16 | ||
*/ | ||
|
||
return [ | ||
'robot_webhook' => env('DD_WEBHOOK', ''), //叮叮机器人请求地址 | ||
'notice_active' => env('DD_NOTICE_ACTIVE', true) | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# 叮叮机器人sdk | ||
|
||
For laravel >= 5.5 | ||
|
||
> composer require dishcheng/dd_notice | ||
[官方设置说明](https://open-doc.dingtalk.com/docs/doc.htm?spm=a219a.7629140.0.0.karFPe&treeId=257&articleId=105735&docType=1) | ||
|
||
sdk设置说明 | ||
> php artisan vendor:publish --tag=dd_notice | ||
将webhook地址粘贴到config/dd_notice.php中的robot_webhook位置 | ||
|
||
文本推送方法: | ||
``` | ||
use DishCheng\DdNotice\DdNotice; | ||
DdNotice::send([ | ||
'msgtype' => 'text', | ||
'text' => [ | ||
'content' => '测试文本' | ||
] | ||
]); | ||
``` | ||
|
||
更多方法参考官方设置说明 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace DishCheng\DdNotice; | ||
|
||
use GuzzleHttp\Client; | ||
use Illuminate\Support\Facades\Facade; | ||
|
||
/** | ||
* Created by PhpStorm. | ||
* User: caicheng | ||
* Date: 2018-11-28 | ||
* Time: 18:42 | ||
*/ | ||
class DdNotice extends Facade | ||
{ | ||
public static function send(array $params) | ||
{ | ||
$client = new Client(); | ||
try { | ||
if (config('dd_notice.notice_active')) { | ||
$res = $client->request('post', config('dd_notice.robot_webhook'), | ||
[ | ||
'headers' => | ||
[ | ||
'Content-Type' => 'application/json;charset=utf-8', | ||
], | ||
'body' => json_encode($params), | ||
] | ||
); | ||
return $res->getBody(); | ||
} | ||
} catch (\GuzzleHttp\Exception\GuzzleException $exception) { | ||
\Log::error(json_encode($exception->getMessage())); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace DishCheng\DdNotice; | ||
|
||
use Illuminate\Support\ServiceProvider; | ||
|
||
class DdNoticeProvider extends ServiceProvider | ||
{ | ||
/** | ||
* Boot the service provider. | ||
* | ||
* @return void | ||
*/ | ||
public function boot() | ||
{ | ||
$this->publishes([ | ||
__DIR__ . '/../config' => config_path(),], | ||
'dd_notice' | ||
); | ||
} | ||
|
||
public function register() | ||
{ | ||
$this->app->bind(DdNotice::class, function () { | ||
return new DdNotice(); | ||
}); | ||
} | ||
} |