目前支持的自定义群机器人和通用消息类型
APP | 名称 | 文本 | markdown | 图文 | 卡片 |
---|---|---|---|---|---|
企业微信 | √ | √ | √ | √ | |
钉钉 | dingtalk | √ | √ | √ | √ |
飞书 | feishu | √ | √ | √ | √ |
Via Composer
$ composer require ymlluo/group-robot
初始化
$robot = new GroupRobot('wechat');
//设置 webhook 发送地址
$webhook = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=693a91f6-7xxx-4bc4-97a0-0ec2sifa5aaa';
$robot->to($webhook);
//或者初始化直接指定
$robot = new GroupRobot('wechat',$webhook);
//或者最后发送的时候设置
$robot = $robot->text('hello')->send($webhook);
文本
$robot->text('hello world', ['mentioned_list' => ['@all'],'mentioned_mobile_list'=>['@all']])->send();
Markdown
$robot->markdown("实时新增用户反馈<font color=\"warning\">132例</font>,请相关同事注意。")->send();
图片
//网络图片
$robot->image('http://res.mail.qq.com/node/ww/wwopenmng/images/independent/doc/test_pic_msg1.png')->send();
//发送本地图片
$robot->image('/tmp/images/test_pic_msg1.png')->send();
文件
//网络文件
$robot->file('http://www.gov.cn/zhengce/pdfFile/2021_PDF.pdf','政府信息公开目录.pdf')->send();
//本地文件
$robot->file('/tmp/pdfFile/2021_PDF.pdf','政府信息公开目录.pdf')->send();
图文
//单条图文
$robot->news([
'title' => '中秋节礼品领取',
'description' => '今年中秋节公司有豪礼相送',
'url' => 'www.qq.com',
'picurl' => 'http://res.mail.qq.com/node/ww/wwopenmng/images/independent/doc/test_pic_msg1.png'
])->send();
//多条图文
$robot->news([
[
'title' => '胡彦斌,不再为爱情燃烧',
'description' => '胡彦斌最被大众好奇的问题是:他现在会如何看待感情?',
'url' => 'https://new.qq.com/omn/20211028/20211028A07EDT00.html',
'picurl' => 'https://inews.gtimg.com/newsapp_bt/0/14116849898/1000'
],
[
'title' => '中秋节礼品领取',
'description' => '今年中秋节公司有豪礼相送',
'url' => 'www.qq.com',
'picurl' => 'http://res.mail.qq.com/node/ww/wwopenmng/images/independent/doc/test_pic_msg1.png'
]
])->send();
模版卡片
$robot->card([
'card_type' => 'text_notice',
'source' => [
'icon_url' => 'https://wework.qpic.cn/wwpic/252813_jOfDHtcISzuodLa_1629280209/0',
'desc' => '企业微信',
],
'main_title' => [
'title' => '欢迎使用企业微信',
'desc' => '您的好友正在邀请您加入企业微信',
],
'emphasis_content' => [
'title' => '100',
'desc' => '数据含义',
],
'sub_title_text' => '下载企业微信还能抢红包!',
'horizontal_content_list' => [
0 => [
'keyname' => '邀请人',
'value' => '张三',
],
1 => [
'keyname' => '企微官网',
'value' => '点击访问',
'type' => 1,
'url' => 'https://work.weixin.qq.com/?from=openApi',
]
],
'jump_list' => [
0 => [
'type' => 1,
'url' => 'https://work.weixin.qq.com/?from=openApi',
'title' => '企业微信官网',
]
],
'card_action' => [
'type' => 1,
'url' => 'https://work.weixin.qq.com/?from=openApi',
'appid' => 'APPID',
'pagepath' => 'PAGEPATH',
],
])->send();
钉钉-自定义机器人接入 文本
$robot->text('hello world', ['atMobiles' => ['180xxxxxx'],'atUserIds'=>['user123'],'isAtAll'=>false])->send();
Markdown
TODO
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
MIT. Please see the license file for more information.