ro4/ding-robot

A php library for ding ding group robot. 钉钉群机器人库

1.0.0 2018-06-15 04:46 UTC

This package is not auto-updated.

Last update: 2024-04-28 03:30:49 UTC


README

钉钉机器人 PHP 库
Build Status Scrutinizer Code Quality Code Coverage Build Status Code Intelligence Status

使用前先阅读钉钉官方文档

使用方法

  1. composer require ro4/ding-robot 引入。

  2. demo

<?php

require_once "./vendor/autoload.php";

d_web_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();