PHP code example of ritaswc / wechat-work-robot

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

    

ritaswc / wechat-work-robot example snippets


$key = 'a45bxxxx-xxxx-xxxx-xxxx-fbf0a09cxxxx';
$robot = new \Ritaswc\WechatWorkRobot\WechatWorkRobot($key);

$robot->sendText('PHP is the best language in the world!', ['huixinchen', '@all']);
$robot->sendText('PHP is the best language in the world!', [], ['199****1322', '@all']);

$robot->sendImage('wechatpay.png');
$robot->sendImage('https://blogoss.yinghualuo.cn/blog/2019/05/wechatpay.png');

$robot->sendMarkDown("## 欢迎使用支付宝赞助
## 欢迎使用微信赞助");

$robot->sendNews([
    [
        'title'       => 'Charles的小星球',
        'description' => '一个PHP码农的自述',
        'url'         => 'https://blog.yinghualuo.cn',
        'picurl'      => 'https://blog.yinghualuo.cn/wp-content/themes/twentyseventeen/assets/images/header.jpg',
    ],
    [
        'title'       => 'Charles的小星球1',
        'description' => '一个PHP码农的自述1',
        'url'         => 'https://blog.yinghualuo.cn',
        'picurl'      => 'https://blog.yinghualuo.cn/wp-content/themes/twentyseventeen/assets/images/header.jpg',
    ]
]);