ifree/dingtalk

钉钉机器人SDK

This package's canonical repository appears to be gone and the package has been frozen as a result.

1.0.1 2017-10-19 10:01 UTC

This package is auto-updated.

Last update: 2020-04-03 07:41:26 UTC


README

钉钉机器人SDK

安装

通过composer

composer require ifree\dingtalk

使用

实例化对象

use ifree\Dingtalk;

// 方法一
$ding = new Dingtalk();
// 直接设置token
$ding->setToken('xxx');

// 方法二
$ding = new Dingtalk();
// 添加多个机器人
$ding->addRobot('myrobot1', 'xxx');
$ding->addRobot('myrobot2', 'xxx');
// 设置使用机器人
$ding->setRobot('myrobot1');

// 方法三
$robots = array(
	'myrobot1' => 'xxx',
	'myrobot2' => 'xxx',
);
// 通过配置项设置
$ding = new Dingtalk($robots);
$ding->setRobot('myrobot1');

调用方法

text类型

// 正常发送
$ding->text('hello world');

// @某人
$ding->text('hello world', [
	'对方的手机号',
]);

// @所有人
$ding->text('hello world', [], true);

link类型

// 正常发送
$ding->link('hello world', 'title');

// 带跳转地址和图片
$ding->link('hello world', 'title', 'target url', 'pic url');

markdown类型

// 正常发送
$ding->markdown('title', "#### markdown\n> hello world");

// @某人
$ding->markdown('title', "#### markdown\n> hello world", [
	'对方的手机号',
]);

// @所有人
$ding->markdown('title', "#### markdown\n> hello world", [], true);

actionCard类型

$ding->actionCard('title', "# hello\nworld", ['我是按钮' => '我是跳转链接']);

feedCard类型

$ding->feedCard([
	'我是内容1' => ['跳转链接', '图片链接'],
	'我是内容2' => ['跳转链接', '图片链接'],
]);