PHP code example of ro4 / ding-robot
1. Go to this page and download the library: Download ro4/ding-robot library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ro4 / ding-robot example snippets
_hook('https://oapi.dingtalk.com/robot/send?access_token=YOURTOKEN');
$picUrl = "http://ww3.sinaimg.cn/mw600/0073tLPGgy1fsbnnn4ldvj30dw0k1n09.jpg";
$md = new \DavidBadura\MarkdownBuilder\MarkdownBuilder();
$md->p($md->inlineImg($picUrl, '福利'));
// 测试文字消息
d_text('测试文字消息')->send();
//
// 测试 @所有人
d_text('测试 at 所有人')->atAll()->send();
//
// 测试 ActionCard
d_action_card('测试整体跳转Action Card', $md->getMarkdown(), '查看高清大图', $picUrl)->send();
// 测试 ActionCard Buttons
$acb = d_action_card_btn('测试带按钮的Action Card', $md->getMarkdown(),
[d_make_btn('图1', $picUrl), d_make_btn('图2', $picUrl)]);
$acb->send();
$acb->showAvatar()->btnOrientationVertical()->title('按钮横向排列')->send();
$acb->hideAvatar()->title('隐藏头像')->send();
d_feed_card([d_make_link('测试 feed card', $picUrl, $picUrl), d_make_link('link2', $picUrl, $picUrl)])->send();
d_link('测试 link', $md->getMarkdown(), $picUrl, $picUrl)->send();
d_markdown('测试 markdown', $md->getMarkdown())->send();