PHP code example of yian / ding-bot-sdk

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

    

yian / ding-bot-sdk example snippets




use Ding\Bot;

$url = 'Your bot webhook url';    // 机器人地址
$options = [
    'secret' => "Your secret",    // 如果安全设置中勾选了“加签”,则需要提供
];
$bot = new Bot($url, $options);

$msg = [
    'msgtype' => 'text',
    'text' => [
        'content' => '大家好',
    ],
];

var_dump($bot->send($msg));
// string(27) "{"errcode":0,"errmsg":"ok"}"