mradang / laravel-dingtalk
laravel-dingtalk
Installs: 1 423
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- laravel/framework: ^10.0|^11.0|^12.0
Requires (Dev)
- laravel/pint: ^1.5
README
封装钉钉接口,处理钉钉事件订阅,触发事件
安装
composer require mradang/laravel-dingtalk
配置
- 添加 .env 环境变量
DINGTALK_CORPID=dingxxxxxxx
DINGTALK_AGENTID=xxxxxxxx
DINGTALK_APPKEY=xxxxxxxx
DINGTALK_APPSECRET=xxxxxxxx
DINGTALK_CALLBACK_AES_KEY=xxxxxxxx
DINGTALK_CALLBACK_TOKEN=xxxxxxxx
DINGTALK_PROXY=http://addr:port
添加的路由
- post /api/dingtalk/config
- post /api/dingtalk/callback
添加的事件
- mradang\LaravelDingTalk\Events\DepartmentCreateEvent
string $deptid
- mradang\LaravelDingTalk\Events\DepartmentModifyEvent
string $deptid
- mradang\LaravelDingTalk\Events\DepartmentRemoveEvent
string $deptid
- mradang\LaravelDingTalk\Events\UserAddEvent
string $userid
- mradang\LaravelDingTalk\Events\UserLeaveEvent
string $userid
- mradang\LaravelDingTalk\Events\UserModifyEvent
string $userid
添加的命令
- 刷新部门和用户(触发变更事件)
php artisan dingtalk:RefreshDepartmentsAndUsers
钉钉接口调用示例
发送工作通知消息
请求方式:POST(HTTPS)
请求地址:https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2?access_token=ACCESS_TOKEN
$params = [ 'agent_id' => env('DINGTALK_AGENTID'), 'userid_list' => '0841582759859766', 'msg' => [ 'msgtype' => 'text', 'text' => [ 'content' => '当前时间:'.date('Y-m-d H:i:s'), ], ], ]; $ret = DingTalk::post('/topapi/message/corpconversation/asyncsend_v2', $params);