PHP code example of leychan / feishu-robot

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

    

leychan / feishu-robot example snippets





    throw new \Exception('hhhh');
} catch (\Exception $e) {
    $webhook = 'your robot webhook';
    $msgType = 'post'; //or text
    (new \Leychan\FeiShuRobot\ExceptionRobot($webhook, $msgType, $e, ''))->notify();
}

try {
    throw new \Exception('hhhh');
} catch (\Exception $e) {
    $webhook = 'your robot webhook';
    $msgType = 'text'; //or text
    (new \Leychan\FeiShuRobot\ExceptionRobot($webhook, $msgType, $e, ''))->notify();
}

try {
    throw new \Exception('hhhh');
} catch (\Exception $e) {
    $webhook = 'your robot webhook';
    $msgType = 'post';
    $params = ['title' => 'test', 'content' => [
        'line1' => 'text',
        'line2' => 'text',
        'line3' => 'text',
    ]];
    (new \Leychan\FeiShuRobot\CommonRobot($webhook, $msgType, $params))->notify();
}

try {
    throw new \Exception('hhhh');
} catch (\Exception $e) {
    $webhook = 'your robot webhook';
    $msgType = 'text';
    (new \Leychan\FeiShuRobot\ExceptionRobot($webhook, $msgType, $e))->notify();
    //$msgType = 'post';
    //title is only effect when msgType='post'
    //(new \Leychan\FeiShuRobot\ExceptionRobot($webhook, $msgType, $e, 'title'))->notify();
}