PHP code example of saviorlv / yii2-dingtalk
1. Go to this page and download the library: Download saviorlv/yii2-dingtalk library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
saviorlv / yii2-dingtalk example snippets
'components' => [
.....
'robot' => [
'class' => 'Saviorlv\Dingtalk\Robot',
'accessToken' => 'xxxxxxxxx'
],
....
]
public function sendTextMsg($content, array $atMobiles = [], $isAtAll = false){}
$response = Yii::$app->robot->sendTextMsg(
"必要忘记上下班打卡",
[
136*****134,
136*****132
],
false
);
public function sendLinkMsg($title, $text, $picUrl = '', $messageUrl){}
$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"
);
public function sendMarkdownMsg($title, $content, array $atMobiles = [], $isAtAll = false){}
$response = Yii::$app->robot->sendMarkdownMsg(
"上下班打卡",
" ###有些同志上下班就是不打卡,`QAQ`",
[
136*****134,
136*****132
],
false
);
public function sendActionCardMsg($title, $content, $singleURL, $hideAvatar = 0, $btnOrientation = 0, $singleTitle = '阅读原文'){}
$response = Yii::$app->robot->sendActionCardMsg(
"上下班打卡",
" 有些同志上下班就是不打卡,QAQ",
"https://github.com/saviorlv?tab=repositories",
0,
0,
"你看不看"
);
public function sendSingleActionCardMsg($title, $content, $hideAvatar = 0, $btnOrientation = 0, array $btns=[]){}
$response = Yii::$app->robot->sendSingleActionCardMsg(
"上下班打卡",
" 有些同志上下班就是不打卡,QAQ",
0,
1,
[
[
"title"=> "内容不错",
"actionURL"=> "https://www.dingtalk.com/"
],
[
"title"=> "不感兴趣",
"actionURL"=> "https://www.dingtalk.com/"
]
]
);
public function sendFeedCardMsg(array $links=[]){}
$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"
],
]);