forked from kokonior/PHP-Projects
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathargadw.php
103 lines (83 loc) · 2.81 KB
/
argadw.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
function provinsi()
{
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, "https://api.kawalcorona.com/indonesia/provinsi/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$test = curl_exec($ch);
curl_close($ch);
$de = json_decode($test);
for ($i=0;$i<=33;$i++)
{
$tab = $i + 1;
echo "\t\t". $tab . ". Kasus Di ".$de[$i]->attributes->Provinsi . "\n". PHP_EOL;
echo "Positif : ".$de[$i]->attributes->Kasus_Posi . PHP_EOL;
echo "Sembuh : ".$de[$i]->attributes->Kasus_Semb . PHP_EOL;
echo "Meninggal : ".$de[$i]->attributes->Kasus_Meni . PHP_EOL;
echo "\n";
}
}
function indonesia()
{
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,"https://api.kawalcorona.com/indonesia/");
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
$indonesia = curl_exec($ch);
curl_close($ch);
$de = json_decode($indonesia);
echo "\t\tKasus Di {$de[0]->name}\n" . PHP_EOL;
echo "Positif : {$de[0]->positif}" . PHP_EOL;
echo "Sembuh : {$de[0]->sembuh}" . PHP_EOL;
echo "Meninggal : {$de[0]->meninggal}" . PHP_EOL;
echo "Dirawat : {$de[0]->dirawat}\n" . PHP_EOL;
}
function dunia()
{
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, "https://api.kawalcorona.com/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$glo = curl_exec($ch);
curl_close($ch);
$positif = curl_init();
curl_setopt($positif,CURLOPT_URL, "https://api.kawalcorona.com/positif/");
curl_setopt($positif, CURLOPT_RETURNTRANSFER, 1);
$pos = curl_exec($positif);
curl_close($positif);
$sembuh = curl_init();
curl_setopt($sembuh,CURLOPT_URL, "https://api.kawalcorona.com/sembuh/");
curl_setopt($sembuh,CURLOPT_RETURNTRANSFER,1);
$sehat = curl_exec($sembuh);
curl_close($sembuh);
$sembuhsehat = json_decode($sehat);
var_dump($sembuhsehat);
$decosat = json_decode($pos);
$deco = json_decode($glo);
var_dump($decosat);
for ($i=0;$i<=191;$i++)
{
$tab = $i + 1;
echo "\t\t". $tab . ". Kasus Di ".$deco[$i]->attributes->Country_Region . "\n". PHP_EOL;
echo "Positif : ".$deco[$i]->attributes->Confirmed . PHP_EOL;
echo "Sembuh : ".$deco[$i]->attributes->Recovered . PHP_EOL;
echo "Meninggal : ".$deco[$i]->attributes->Deaths . PHP_EOL;
echo "\n";
}
echo "{$decosat->name} : {$decosat->value} " . PHP_EOL;
echo "{$sembuhsehat->name} : {$sembuhsehat->value} " . PHP_EOL;
}
echo "\t\tAPI DARI KAWALCORONA.COM\n" . PHP_EOL;
echo "1. Statistik Kasus Coronavirus di Indonesia\n";
echo "2. Statistik Kasus Coronavirus di Provinsi\n";
echo "3. Statistik Kasus Coronavirus di Dunia\n\n";
echo "Pilih No : ";
$api = fgets(STDIN);
if ($api == 1)
{
indonesia();
} elseif ($api == 2)
{
provinsi();
} elseif ($api == 3)
{
dunia();
}