dingtalk chatbot
1.0.3
采用面向对象的开发方法
git clone [email protected]:baiyutang/dingtalk-robot.git或composer require baiyutang/dingtalk-robotsrc/config.php文件中$groups数组中,修改钉钉群机器人为推送的目标群 token- 参照示例组装代码
Config.php 文件中数组,配置 array('group_name'=>'...your token...'),然后 $client = new ChatBot('group_name');$client = new ChatBot('param'),当构造函数接收到的参数不在 Config.php 的 $groups 数组的键中,会被认定是一个 token// text 类型
use DingTalkRobotAt;
use DingTalkRobotGroupChat;
use DingTalkRobotMessagesTextMessage;
use DingTalkRobotChatBot;
// 链式调用设置 @ 多个手机号
$at = new At();
$at->setMobile('181****3753')
->setMobile('181****3751');
// 链式调用设置消息内容
$message = new TextMessage();
$message->setContent('我就是我, 是不一样的烟火')
->setAt($at);
$client = new ChatBot();
// 可以指定群,若不设置则发送默认的群
$client->send($message, new GroupChat('other'));// markdown 类型
use DingTalkRobotGroupChat;
use DingTalkRobotMessagesMarkdownMessage;
use DingTalkRobotChatBot;
$markdown = new MarkdownMessage();
$markdown->setTitle('杭州天气')
->setText("#### 杭州天气n" .
"> 9度,西北风1级,空气良89,相对温度73%n" .
"> n" .
"> 10点20分发布 [天气](http://www.thinkpage.cn/)");
$client = new ChatBot();
$client->send($markdown, new GroupChat());MIT license