-
Notifications
You must be signed in to change notification settings - Fork 12
/
index.php
52 lines (49 loc) · 1.4 KB
/
index.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
<?php
/*
BMKG API web scrapping :D
file name : index.php
Created : 14 November 2018
by : bangjii (al.ghifari22@gmail.com)
http://iotcampus.net/bmkg/?menu=%menu%&wilayah=%wilayah%
menu : - cuaca
- gempa
wilayah : bisa diisi nama provinsi seperti "dki jakarta", "aceh"
atau diisi "list" untuk melihat list provinsi yang terdaftar
contoh :
http://iotcampus.net/bmkg/?menu=cuaca&wilayah=jambi
http://iotcampus.net/bmkg/?menu=cuaca&wilayah=list
http://iotcampus.net/bmkg/?menu=gempa
*/
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
header("Access-Control-Allow-Methods: GET");
header("Access-Control-Max-Age: 3600");
header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
include "./gempa.php";
include "./cuaca.php";
$menu = $_GET['menu'];
$wilayah = $_GET['wilayah'];
if(isset($menu)){
if($menu == "cuaca"){
if(isset($wilayah)){
$wil = strtolower($wilayah);
if($wil != ""){
$cuacaJson = cuaca($wil);
print($cuacaJson);
}
}
}
elseif($menu == "gempa"){
$gempaJson = gempa();
print($gempaJson);
} else {
$err = json_encode(array("error wrong parameter!"));
print($err);
die();
}
} else {
$err = json_encode(array("error wrong method!"));
print($err);
die();
}
?>