PHP code example of surprise-tech / dingtalk_api

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

    

surprise-tech / dingtalk_api example snippets


$dingtalk = new DingTalkServices('hy');
$data = getData($dingtalk, 'PROC--***', 1, $startTime, $endTime);
dd($data);
function getData($dingtalk, $processCode, $next, $startTime, $endTime, $user_id = null, $data = [])
{
    $rs = $dingtalk->processGetList($processCode, $startTime, $endTime, $user_id, $next);
    $list = $rs->body?->result?->list;
    $data = array_merge($data, $list);
    $nextToken = $rs->body?->result?->nextToken;
    if (!empty($nextToken)) {
        echo "下一页:{$nextToken} \n";
        $data = getData($dingtalk, $processCode, $nextToken, $startTime, $endTime, $user_id, $data);
    }

    return $data;
}

echo "获取详情:\n";
foreach ($data as $key => $item) {
    $rs = $dingtalk->processGetInfo($item);
    echo "标题:{$rs->body?->result?->title} \n";
}