-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.php
58 lines (41 loc) · 999 Bytes
/
api.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
// membuat fungsi req
function http_request($url){
$ch = curl_init();
//set url
curl_setopt($ch, CURLOPT_URL, $url);
//aktifkan fungsi
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//setting agar bisa di jalankan
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
//tampung hasil ke dalam var
$output = curl_exec($ch);
// tutup curl
curl_close($ch);
// mengembalikan curl
return $output;
}
// panggil fungsi httprequest
$data = http_request("https://api.kawalcorona.com/indonesia/provinsi/");
//ubah format json
$data =json_decode($data,TRUE);
//echo"<pre>";
//print_r($data);
//echo"</pre>";
//tampung jumlah data
$jumlah = count($data);
$nomor = 1;
for($i = 0; $i < $jumlah; $i++){
$hasil= $data[$i]['attributes'];
?>
<tr>
<td><?=$nomor++?></td>
<td><?=$hasil['Provinsi']?></td>
<td><?=$hasil['Kasus_Posi']?></td>
<td><?=$hasil['Kasus_Semb']?></td>
<td><?=$hasil['Kasus_Meni']?></td>
</tr>
<?php
}
?>