PHP code example of atshike / yida_api
1. Go to this page and download the library: Download atshike/yida_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/ */
atshike / yida_api example snippets
// 批量获取列表
use Atshike\YidaApi\Services\YiDaServices;
$yd = new YiDaServices();
$data = getData($yd,'FORM-******', 1, 'user_id', [ 'feilds' => 'RUNNING']);
function getData($yd, $formUuid, $next, $user_id, $params, $data = [])
{
$rs = $yd->getFormList($formUuid, $user_id, $params, $next, 10);
$list = $rs->body?->data;
$currentPage = $rs->body?->currentPage; // 当前页
$totalCount = $rs->body?->totalCount; // 实例总数
$data = array_merge($data, (array) $list);
if ($currentPage < ceil($totalCount / 100)) {
echo "下一页:{$currentPage}/$totalCount \n";
$data = getData($yd, $formUuid, bcadd($next, 1), $user_id, $params, $data);
}
return $data;
}
// 获取附件地址
$dingtalk = new YiDaService();
$rs = $dingtalk->downloadAttUrl("https://{$params['url']}{$params['file']}");
$url = $rs->body->result;
// 打开远程文件
$client = new Client(['verify' => false]);
$tempData = $client->request('get', $url)->getBody()->getContents();
// 保存到本地
$rs = Storage::disk('files')->put("/time().xlsx", $tempData);