PHP code example of lingan / dingtalk-notice

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

    

lingan / dingtalk-notice example snippets


return [
    'robot_base_url' => env('DING_ROBOT_URL', 'https://oapi.dingtalk.com/robot/send'),
    'timeout'        => 2.0,
    'access_token'   => [
        'default' => env('DING_TOKEN', '你的钉钉群组机器人token'),// 默认
        'others'  => [ // 扩展更多token,预留
            'xxx' => env('XXX_TOKEN', '你的钉钉群组机器人token'),
        ],
    ],
];
shell
php artisan vendor:publish
bash

配置文件
$config = [
    'robot_base_url' => 'https://oapi.dingtalk.com/robot/send',
    'timeout' => 2.0,
    'access_token' => [
        'default' => '你的钉钉群组机器人token',// 默认
    ],
];
// 实例化
$dingtalk = new \Lingan\DingtalkNotice\DingtalkNotice($config);

// 发送
$dingtalk->useRobot()
->getInstance()
->setTextMessage('这里是报错信息')
->setAtMobiles(['188xxxxxxxx'])
->send();