hughcube/laravel-dingtalk
laravel dingtalk
Installing
$ composer require hughcube/laravel-dingtalk -vvv
Configuration
[
/**
* default config
*/
'defaults' => [],
'robots' => [
'default' => [
'enabled' => env('DING_TALK_ROBOT_ENABLED', true),
/**
* The full webhook url, e.g. https://oapi.dingtalk.com/robot/send?access_token=xxx
*/
'url' => env('DING_TALK_ROBOT_URL', ''),
/**
* The robot access_token, the default url will be generated automatically
*/
'access_token' => env('DING_TALK_ROBOT_ACCESS_TOKEN', ''),
/**
* The robot secret, timestamp and sign will be appended automatically
*/
'secret' => env('DING_TALK_ROBOT_SECRET', ''),
]
]
]
Configure either url or access_token, they are interchangeable:
# option 1: the full webhook url
DING_TALK_ROBOT_URL=https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxx
# option 2: only the access_token
DING_TALK_ROBOT_ACCESS_TOKEN=xxxxxxxx
When both are configured the url wins. If the robot has a secret (DING_TALK_ROBOT_SECRET=SECxxxxxxxx),
timestamp and sign are appended to the url automatically in both modes.
Usage
use HughCube\Laravel\DingTalk\DingTalk;
use HughCube\Laravel\DingTalk\Robot\Messages\Text;
DingTalk::robot()->send(new Text('hello world'));
// multi robot
DingTalk::robot('other')->send(new Text('hello world'));
Log channel
'channels' => [
'dingtalk' => [
'driver' => 'monolog',
'handler' => HughCube\Laravel\DingTalk\Log\Handler::class,
'with' => [
'robot' => null, // the robot name, null means "default"
'enabled' => env('DING_TALK_ROBOT_ENABLED', true),
'level' => 'warning',
],
],
],
Test
$ composer test
# integration test against a real robot (optional)
$ DING_TALK_ROBOT_URL='https://oapi.dingtalk.com/robot/send?access_token=xxx' DING_TALK_ROBOT_SECRET='SECxxx' ./vendor/bin/phpunit
Contributing
You can contribute in one of three ways:
- File bug reports using the issue tracker.
- Answer questions or fix bugs on the issue tracker.
- Contribute new features or update the wiki.
The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable.
License
MIT
Related Packages
Powerful PHP database abstraction layer (DBAL) with many features for database s...
Laravel Serializable Closure provides an easy and secure way to serialize closur...
Cli error handling for console/command-line PHP applications.
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| v1.2.0 | 8.* | MIT | ||
| v1.1.1 | 8.* | MIT | ||
| v1.1.0 | 8.* | MIT | ||
| v1.0.5 | 8.* | MIT | ||
| v1.0.4 | 8.* | MIT | ||
| v1.0.3 | 8.* | MIT | ||
| v1.0.2 | 8.* | >=8.0 | MIT | |
| v1.0.1 | 8.* | >=8.0 | MIT | |
| v1.0.0 | 8.* | >=8.0 | MIT |