Advertisement
Guest User

Olah Data API Pilkada 2017

a guest
Feb 16th, 2017
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. $apis = json_decode(file_get_contents('https://pilkada2017.kpu.go.id/api/hasil.json'));
  3. $a = $b = '';
  4. echo '<!DOCTYPE html><html><head><title>Hasil Perolehan Sementara Pilkada 2017</title><body><h1>Hasil Perolehan Sementara Pilkada 2017</h1><br />Berikut ini adalah data hasil perolehan suara pilkada 2017 untuk masing-masing wilayah yang kami peroleh dari Public API (Application Programming Interface) KPU (Komisi Pemilihan Umum) yang beralamatkan di https://pilkada2017.kpu.go.id/api/hasil.json.<br />';
  5. echo 'Data API Pilkada berdasarkan entry data Model C1 yang bisa dilihat pada https://pilkada2017.kpu.go.id bukan hasil resmi dan final.<br />Kesalahan yang terdapat pada Model C1 akan diperbaiki pada proses rekapitulasi pada tingkat diatasnya.<br /><br />';
  6. foreach($apis as $api) {
  7.     if($a == $api->idWilayah) {  } else {
  8.         $a = $api->idWilayah;
  9.         if($a == 1) { } else { echo '</tbody></table><br /><br />'."\n"; }
  10.         echo '<table border="1"><tbody>'."\n";
  11.         echo '<tr><th colspan="3">'.$api->namaPemilihan.' - '.$api->namaWilayah.' - '.$api->namaPropinsi.'</th></tr>'."\n";
  12.         echo '<tr><th>Nomor Urut</th><th>Pasangan Calon</th><th>Perolehan Suara</th></tr>'."\n";   
  13.     }
  14.     if($b == $api->nomorUrut) { } else {
  15.         $b = $api->nomorUrut;
  16.     }
  17.     echo '<tr><td>'.$b.'</td><td>'.$api->namaKd.' / '.$api->namaWkd.'</td><td>'.$api->jumlahSuara.'</td>'."\n";
  18. }
  19. echo '</tbody></table>';
  20. echo '<br /><br />Semoga bermanfaat, <a href="http://teguhaditya.com">Teguh</a>';
  21. echo '<br />Contoh hasil script ini dapat anda lihat di http://1n.pw/pilkada2017.php';
  22. echo '</body></html>';
  23. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement