当前自定义机器人支持
文本(text)、链接(link)、markdown(markdown)三种消息类型
大家可以根据自己的使用场景选择合适的消息类型,达到最好的展示样式
composer require wxiangqian/laravel-dingtalk
composer install
或
composer.json 中添加 "wxiangqian/laravel-dingtalk": "^1.2.0"
composer install
1.0为版本号,可替换 如果无法安装 请执行一下 composer update nothing 然后 composer update
在config/app.php 'providers' 中添加
\Qian\DingTalk\DingTalkServiceProvider::class
php artisan vendor:publish
则生成 config/dingtalk.php
$token可以去调用dingtalk.php里面的talk中的token
因为有时候一个项目会需要配置多个群的通知
所以决定修改的更灵活一点
$DingTalk = new DingTalk();
$message = new Message();
$data = $message->text('测试text类型');
$res = $DingTalk->send($token,$data);
echo $res;
$DingTalk = new DingTalk();
$message = new Message();
$title = '测试link类型title';
$text = '测试link类型text';
$messageUrl = 'https://www.baidu.com/';
$picUrl = '';
$data = $message->link($title, $text, $messageUrl, $picUrl);
$res = $DingTalk->send($token,$data);
echo $res;
$DingTalk = new DingTalk();
$message = new Message();
$title = '北京天气MD';
$text = '# laravel-DingTalk是基于laravel5.5开发的钉钉机器人';
$data = $message->markdown($title, $text);
$res = $DingTalk->send($token,$data);
echo $res;