1. Go to this page and download the library: Download smansage/dapodik-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/ */
// Tarik seluruh siswa sekolah secara otomatis
$semuaSiswa = $client->fetchAllPesertaDidik(
limit: 100,
delayMs: 150, // Jeda 150ms per halaman agar server Dapodik tidak overload
onProgress: function (int $page, int $batchCount, int $totalCount) {
echo "Halaman {$page}: ditarik +{$batchCount} siswa (Total terakumulasi: {$totalCount})\n";
}
);
echo "Total seluruh siswa: " . $semuaSiswa->count() . "\n";
use Smansage\Dapodik\Exceptions\DapodikAuthException;
use Smansage\Dapodik\Exceptions\DapodikConnectionException;
use Smansage\Dapodik\Exceptions\DapodikHttpException;
use Smansage\Dapodik\Exceptions\DapodikException;
try {
$siswa = Dapodik::getPesertaDidik();
} catch (DapodikAuthException $e) {
// Error 401/403: Token salah atau IP client belum di-whitelist di Dapodik
logger()->error("Autentikasi gagal: " . $e->getMessage());
} catch (DapodikConnectionException $e) {
// Server Dapodik mati / port 5774 tidak bisa diakses
logger()->error("Koneksi gagal: " . $e->getMessage());
} catch (DapodikHttpException $e) {
// Error HTTP 500/404 dari WebService
logger()->error("HTTP Error [{$e->getCode()}]: " . $e->getMessage());
} catch (DapodikException $e) {
// Error umum lainnya
logger()->error("Dapodik Error: " . $e->getMessage());
}