PHPackages                             saviorlv/yii2-dingtalk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. saviorlv/yii2-dingtalk

ActiveLibrary

saviorlv/yii2-dingtalk
======================

Yii2 DingTalk robot SDk

0.0.2(7y ago)21701MITPHPPHP &gt;=5.5.0

Since Sep 8Pushed 7y ago1 watchersCompare

[ Source](https://github.com/sunmking/yii2-dingtalk)[ Packagist](https://packagist.org/packages/saviorlv/yii2-dingtalk)[ Docs](https://github.com/saviorlv/yii2-dingtalk)[ RSS](/packages/saviorlv-yii2-dingtalk/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (2)Versions (3)Used By (1)

yii2-dingtalk 钉钉群机器人
====================

[](#yii2-dingtalk-钉钉群机器人)

说明
--

[](#说明)

> 群机器人是钉钉群的高级扩展功能。群机器人可以将第三方服务的信息聚合到群聊中，实现自动化的信息同步。目前，大部分机器人在添加后，还需要进行Webhook配置，才可正常使用(配置说明详见操作流程中的帮助链接)。

> 例如：通过聚合GitHub，GitLab等源码管理服务，实现源码更新同步。通过聚合Trello，JIRA等项目协调服务，实现项目信息同步。

> 另外，群机器人支持Webhook协议的自定义接入，支持更多可能性，例如：你可将运维报警通过自定义机器人聚合到钉钉群实现提醒功能。

安装
--

[](#安装)

```
$ composer require saviorlv/yii2-dingtalk -vvv
```

配置
--

[](#配置)

在使用本扩展之前，你需要去 [群机器人](https://open-doc.dingtalk.com/microapp/serverapi2/nr29om) 获取相关信息。

使用
--

[](#使用)

> 在config/main.php配置文件中定义component配置信息

```
'components' => [
  .....
  'robot' => [
      'class' => 'Saviorlv\Dingtalk\Robot',
      'accessToken' => 'xxxxxxxxx'
    ],
  ....
]
```

### 发送 `Text` 信息

[](#发送-text-信息)

方法：

```
public function sendTextMsg($content, array $atMobiles = [], $isAtAll = false){}
```

参数：

参数参数类型必须说明contentString是消息内容atMobilesArray否被@人的手机号isAtAllbool否@所有人时：true，否则为：false实例：

```
$response = Yii::$app->robot->sendTextMsg(
    "必要忘记上下班打卡",
    [
        136*****134,
        136*****132
    ],
    false
);
```

### 发送 `Link` 链接

[](#发送-link-链接)

方法：

```
public function sendLinkMsg($title, $text, $picUrl = '', $messageUrl){}
```

参数：

参数参数类型必须说明titleString是消息标题textString是消息内容。如果太长只会部分展示messageUrlString是点击消息跳转的URLpicUrlString否图片URL实例：

```
$response = Yii::$app->robot->sendLinkMsg(
    "上下班打卡",
    "有些同志上下班就是不打卡，QAQ",
    "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1536321778370&di=46a7abc85f6fe1de8df8fbdc5b95d68d&imgtype=0&src=http%3A%2F%2Fimg4.duitang.com%2Fuploads%2Fitem%2F201407%2F21%2F20140721224026_KU3GA.thumb.700_0.jpeg",
    "https://github.com/saviorlv?tab=repositories"
);
```

### 发送 `MarkDown` 消息

[](#发送-markdown-消息)

方法：

```
public function sendMarkdownMsg($title, $content, array $atMobiles = [], $isAtAll = false){}
```

参数：

参数必选类型说明titletruestring首屏会话透出的展示内容contenttruestringmarkdown格式的消息atMobilesArray否被@人的手机号(在text内容里要有@手机号)isAtAllbool否@所有人时：true，否则为：false实例：

```
$response = Yii::$app->robot->sendMarkdownMsg(
        "上下班打卡",
        " ###有些同志上下班就是不打卡，`QAQ`",
        [
            136*****134,
            136*****132
        ],
        false
    );
```

### 整体跳转 `ActionCard`类型

[](#整体跳转-actioncard类型)

方法：

```
public function sendActionCardMsg($title, $content, $singleURL, $hideAvatar = 0, $btnOrientation = 0, $singleTitle = '阅读原文'){}
```

参数：

参数必选类型说明titletruestring首屏会话透出的展示内容contenttruestringmarkdown格式的消息singleTitletruestring单个按钮的方案。(设置此项和singleURL后btns无效)singleURLtruestring点击singleTitle按钮触发的URLbtnOrientationfalsestring0-按钮竖直排列，1-按钮横向排列hideAvatarfalsestring0-正常发消息者头像，1-隐藏发消息者头像实例：

```
$response = Yii::$app->robot->sendActionCardMsg(
        "上下班打卡",
        " 有些同志上下班就是不打卡，QAQ",
        "https://github.com/saviorlv?tab=repositories",
        0,
        0,
        "你看不看"
    );
```

### 独立跳转 `ActionCard` 类型

[](#独立跳转-actioncard-类型)

方法：

```
public function sendSingleActionCardMsg($title, $content, $hideAvatar = 0, $btnOrientation = 0, array $btns=[]){}
```

参数：

参数必选类型说明titletruestring首屏会话透出的展示内容contenttruestringmarkdown格式的消息btnstruearray按钮的信息：title-按钮方案，actionURL-点击按钮触发的URLbtnOrientationfalsestring0-按钮竖直排列，1-按钮横向排列hideAvatarfalsestring0-正常发消息者头像，1-隐藏发消息者头像实例：

```
$response = Yii::$app->robot->sendSingleActionCardMsg(
            "上下班打卡",
            " 有些同志上下班就是不打卡，QAQ",
            0,
            1,
            [
                [
                    "title"=> "内容不错",
                    "actionURL"=> "https://www.dingtalk.com/"
                ],
                [
                    "title"=> "不感兴趣",
                    "actionURL"=> "https://www.dingtalk.com/"
                ]
            ]
        );
```

### `FeedCard` 类型

[](#feedcard-类型)

方法：

```
public function sendFeedCardMsg(array $links=[]){}
```

参数：

参数必选类型说明titletruestring单条信息文本messageURLtruestring点击单条信息到跳转链接picURLtruestring单条信息后面图片的URL实例：

```
  $response = Yii::$app->robot->sendFeedCardMsg([
                [
                    "title"=> "时代的火车向前开",
                    "messageURL"=> "https://mp.weixin.qq.com/s?__biz=MzA4NjMwMTA2Ng==&mid=2650316842&idx=1&sn=60da3ea2b29f1dcc43a7c8e4a7c97a16&scene=2&srcid=09189AnRJEdIiWVaKltFzNTw&from=timeline&isappinstalled=0&key=&ascene=2&uin=&devicetype=android-23&version=26031933&nettype=WIFI",
                    "picURL"=> "http://b.hiphotos.baidu.com/image/pic/item/f603918fa0ec08fa98d87c8054ee3d6d55fbda39.jpg"
                ],[
                    "title"=> "时代的火车向前开",
                    "messageURL"=> "https://mp.weixin.qq.com/s?__biz=MzA4NjMwMTA2Ng==&mid=2650316842&idx=1&sn=60da3ea2b29f1dcc43a7c8e4a7c97a16&scene=2&srcid=09189AnRJEdIiWVaKltFzNTw&from=timeline&isappinstalled=0&key=&ascene=2&uin=&devicetype=android-23&version=26031933&nettype=WIFI",
                    "picURL"=> "http://b.hiphotos.baidu.com/image/pic/item/f603918fa0ec08fa98d87c8054ee3d6d55fbda39.jpg"
                ],
        ]);
```

参考
--

[](#参考)

- [钉钉自定义机器人](https://open-doc.dingtalk.com/microapp/serverapi2/qf2nxq)

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~18 days

Total

2

Last Release

2783d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c9ecc98eec8f6e243c91d53019ffa4d86dab5da58a89d3d23d1523ebe4fec5ea?d=identicon)[sunmking](/maintainers/sunmking)

---

Top Contributors

[![sunmking](https://avatars.githubusercontent.com/u/33918985?v=4)](https://github.com/sunmking "sunmking (9 commits)")

---

Tags

phpsdkyii2dingtalkrobot

### Embed Badge

![Health badge](/badges/saviorlv-yii2-dingtalk/health.svg)

```
[![Health](https://phpackages.com/badges/saviorlv-yii2-dingtalk/health.svg)](https://phpackages.com/packages/saviorlv-yii2-dingtalk)
```

###  Alternatives

[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k7.6M74](/packages/openai-php-laravel)[craftcms/cms

Craft CMS

3.6k3.6M2.6k](/packages/craftcms-cms)[guanguans/notify

Push notification SDK(AnPush、Bark、Chanify、DingTalk、Discord、Gitter、GoogleChat、IGot、Lark、Mattermost、MicrosoftTeams、NowPush、Ntfy、Push、Pushback、PushBullet、PushDeer、PushMe、Pushover、PushPlus、QQ、RocketChat、ServerChan、ShowdocPush、SimplePush、Slack、Telegram、WeWork、WPush、XiZhi、YiFengChuanHua、ZohoCliq、ZohoCliqWebHook、Zulip).

682104.9k7](/packages/guanguans-notify)[resend/resend-php

Resend PHP library.

564.7M21](/packages/resend-resend-php)[onesignal/onesignal-php-api

A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com

34170.2k2](/packages/onesignal-onesignal-php-api)[ory/hydra-client-php

Documentation for all of Ory Hydra's APIs.

1710.8k](/packages/ory-hydra-client-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
