iamzz-cn/dingding-webhook
Composer 安装命令:
composer require iamzz-cn/dingding-webhook
包简介
钉钉群机器人SDK
README 文档
README
dingtalk robot api SDK for PHP
by iamzz
Introduction
The DingTalk group chat robot PHP package version is used to quickly send DingTalk group chat robot messages.
Requirement
- php >= 7.2
- ext-json >= *
Usage
To use this library with Composer, first install it with:
$ composer require iamzz-cn/dingding-webhook
Get the robot's access token through the DingTalk client (pc). It is recommended to sign the security settings (of course you can choose all) to get the access key secret.
use Iamzz\Dingtalk\Dingding; use Iamzz\Dingtalk\MsgType\ActionCard; use Iamzz\Dingtalk\MsgType\FeedCard; use Iamzz\Dingtalk\MsgType\Link; use Iamzz\Dingtalk\MsgType\Markdown; use Iamzz\Dingtalk\MsgType\Text; //Instantiate an instance of the \Iamzz\Dingtalk\Dingding class $dd = new Dingding('token','secret'); //Instantiate the message type instance //textType $message = new Text('我就是我, {a}是不一样的烟火'); $message->setAtMobiles(['a' => '188xxxx8888']); $message->setIsAll(true); //linkType $title = '时代的火车向前开'; $text = '这个即将发布的新版本,创始人xx称它为红树林。而在此之前,每当面临重大升级,产品经理们都会取一个应景的代号,这一次,为什么是红树林'; $messageUrl = 'https://www.dingtalk.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'; $message = new Link($title, $text, $messageUrl); //markdownType $title = '杭州天气'; $text = "#### 杭州天气 {a} \n> 9度,西北风1级,空气良89,相对温度73%\n> \n> ###### 10点20分发布 [天气](https://www.dingtalk.com) \n"; $message = new Markdown($title, $text); $message->setAtMobiles(['a' => '188xxxx8888']); //整体跳转ActionCard类型 $title = '乔布斯 20 年前想打造一间苹果咖啡厅,而它正是 Apple Store 的前身'; $text = "\n ### 乔布斯 20 年前想打造的苹果咖啡厅\n Apple Store 的设计正从原来满满的科技感走向生活化,而其生活化的走向其实可以追溯到 20 年前苹果一个建立咖啡馆的计划"; $buttons = [ '阅读全文' => 'https://www.dingtalk.com/', ]; $message = new ActionCard($title, $text, $buttons); //独立跳转ActionCard类型 $buttons = [ '阅读全文1' => 'https://www.dingtalk.com/', '阅读全文2' => 'https://www.dingtalk.com/', ]; $message = new ActionCard($title, $text, $buttons); //feed card $feedCardData = [ [ 'title' => '时代的火车向前开1', 'messageURL' => 'https://www.dingtalk.com/', 'picURL' => 'https://img.alicdn.com/tfs/TB1NwmBEL9TBuNjy1zbXXXpepXa-2400-1218.png', ], [ 'title' => '时代的火车向前开2', 'messageURL' => 'https://www.dingtalk.com/', 'picURL' => 'https://img.alicdn.com/tfs/TB1NwmBEL9TBuNjy1zbXXXpepXa-2400-1218.png', ], ]; $message = new FeedCard($feedCardData); //Send through the `send()` method of the `\Iamzz\Dingtalk\Dingding` instance object $dd->send($message);
The text and markdown type messages support automatic filling of @ information, for example:
//如果消息体内需要展示出"{",请使用"\{"转义。 use Iamzz\Dingtalk\MsgType\Text; $text = new Text('test content \{a\}'); $text->setAtMobiles(['a'=>'150xxxxxxxx']);
Supported message types
- text类型
- link类型
- markdown类型
- 整体跳转ActionCard类型
- 独立跳转ActionCard类型
- FeedCard类型
iamzz-cn/dingding-webhook 适用场景与选型建议
iamzz-cn/dingding-webhook 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.54k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2020 年 12 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 iamzz-cn/dingding-webhook 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 iamzz-cn/dingding-webhook 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 4.54k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-12-14