PHP code example of pandaxnm / yii2-dingtalk

1. Go to this page and download the library: Download pandaxnm/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/ */

    

pandaxnm / yii2-dingtalk example snippets


    'components' => [
        'robot' => [
            'class' => 'Pandaxnm\DingTalk\Robot',
            'accessToken' => 'YOUR_ACCESS_TOKEN',
        ],
        //other component
    ]

    //send text msg
    Yii::$app->robot->sendTextMsg("I'm a robot!")
    
    //send text msg and @ all
    Yii::$app->robot->sendTextMsg("I'm a robot!", '*')

    //send text msg and @ some persons
    $mobiles = ['13800138000', '13900139000']
    Yii::$app->robot->sendTextMsg("I'm a robot!", $mobiles)
    
    //send link msg
    Yii::$app->robot->sendLinkMsg('this is title','some text','http://baidu.com','http://xxx.com/1.png');
    
    //send markdown msg
    Yii::$app->robot->sendMarkdownMsg("杭州天气", "#### 杭州天气\n 9度,西北风1级,空气良89,相对温度73%");
    
    //send markdown mag and @ all
    Yii::$app->robot->sendMarkdownMsg("杭州天气", "#### 杭州天气\n 9度,西北风1级,空气良89,相对温度73%", '*');
    
    //send markdown msg and @ some persons
    $mobiles = ['13800138000'];
    Yii::$app->robot->sendMarkdownMsg("杭州天气", "#### 杭州天气 @13800138000\n 9度,西北风1级,空气良89,相对温度73%", $mobiles);

    //send actionCard msg
    Yii::$app->robot->sendActionCardMsg("今日新闻", "![screenshot](@lADOpwk3K80C0M0FoA) 
     ### 乔布斯 20 年前想打造的苹果咖啡厅", 'https://dingtalk.com');
     
    //send single actionCard msg
    $btns = [
     [
         'title' => '同意',
         'actionUrl' => 'https://xxx.com/agree'
     ],
     [
         'title' => '拒绝',
         'actionUrl' => 'https://xxx.com/disagree'
     ],
    ];
    Yii::$app->robot->sendSingleActionCardMsg("会议邀请", "### 你有一个会议邀请\n 时间:7月10日 15:00 地点:第一会议室 主题:xxx", $btns, 1, 1);

    $btns = [
        [
            'title' => '标题一',
            'messageUrl' => 'https://gogole.com/1',
            'picURL' => 'https://gogole.com/images/1.jpg'
        ],
        [
            'title' => '标题二',
            'messageUrl' => 'https://gogole.com/2',
            'picURL' => 'https://gogole.com/images/2.jpg'
        ],
    ];
    Yii::$app->robot->sendFeedCardMsg($btns);