PHP code example of hughcube / laravel-dingtalk

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

    

hughcube / laravel-dingtalk example snippets


[
    /**
     * default config
     */
    'defaults' => [],

    'robots' => [
        'default' => [
            'enabled' => env('DING_TALK_ROBOT_ENABLED', true),

            /**
             * The full webhook url, e.g. https://oapi.dingtalk.com/robot/send?access_token=xxx
             */
            'url' => env('DING_TALK_ROBOT_URL', ''),

            /**
             * The robot access_token, the default url will be generated automatically
             */
            'access_token' => env('DING_TALK_ROBOT_ACCESS_TOKEN', ''),

            /**
             * The robot secret, timestamp and sign will be appended automatically
             */
            'secret' => env('DING_TALK_ROBOT_SECRET', ''),
        ]
    ]
]

use HughCube\Laravel\DingTalk\DingTalk;
use HughCube\Laravel\DingTalk\Robot\Messages\Text;

DingTalk::robot()->send(new Text('hello world'));

// multi robot
DingTalk::robot('other')->send(new Text('hello world'));

'channels' => [
    'dingtalk' => [
        'driver'  => 'monolog',
        'handler' => HughCube\Laravel\DingTalk\Log\Handler::class,
        'with'    => [
            'robot'   => null, // the robot name, null means "default"
            'enabled' => env('DING_TALK_ROBOT_ENABLED', true),
            'level'   => 'warning',
        ],
    ],
],