phalapi / dingbot
the library dingtalk group bot of dingtalk group webhookbot for phalapi
dev-master
2020-03-03 06:07 UTC
Requires
- php: >=7.0.0
This package is not auto-updated.
Last update: 2021-11-10 12:29:03 UTC
README
安装
需要使用curl
在composer.json里面添加
"require": {
"phalapi/dingbot":"dev-master"
},
控制台执行 composer update
配置
//./path/to/app.php
return array(
// 钉钉webhook机器人
'DingBot' => array(
'secret'=>'',
'webHook'=>''
),
);
注册
//./path/to/di.php
//钉钉机器人
$di->ddBot = new PhalApi\DingBot\Lite($di->config->get('app.DingBot'));
使用
Text类型消息
\PhalApi\DI()->ddBot->Text('测试');
Link类型消息
\PhalApi\DI()->ddBot->Link('链接','标题','https://www.dingtalk.com');
Markdown类型消息
\PhalApi\DI()->ddBot->Markdown('天气',"#### 杭州天气 @156xxxx8827\n");
ActionCard类型消息,整体跳转ActionCard
\PhalApi\DI()->ddBot
->ActionCard('标题','内容','点击标题','https://www.dingtalk.com');
ActionDialog类型消息,独立跳转ActionCard
\PhalApi\DI()->ddBot->ActionDialog('标题','内容',array(
array('title'=>'标题1','actionURL'=>'https://www.dingtalk.com/'),
array('title'=>'标题2','actionURL'=>'https://www.dingtalk.com/')
)));
FeedCard类型消息
\PhalApi\DI()->ddBot->FeedCard(array(
array('title'=>'标题1',
'messageURL'=>'https://www.dingtalk.com/',
'picURL'=>'https://www.dingtalk.com/'),
array('title'=>'标题2',
'messageURL'=>'https://www.dingtalk.com/',
'picURL'=>'https://www.dingtalk.com/')
)));
更多详细内容参考钉钉官方文档:https://ding-doc.dingtalk.com/doc#/serverapi2/krgddi