· 7 years ago · Jun 18, 2018, 05:38 AM
1<?php
2
3 include "config.php";
4
5 // Computes the timestamp
6 date_default_timezone_set('UTC');
7 $tStamp = strval(time()-strtotime('1970-01-01 00:00:00'));
8 // Computes the signature by hashing the salt with the secret key as the key
9 $signature = hash_hmac('sha256', $consid."&".$tStamp, $secretKey, true);
10 // base64 encode…
11 $encodedSignature = base64_encode($signature);
12
13 $ch = curl_init();
14 $headers = array(
15 'X-cons-id: '.$consid .'',
16 'X-timestamp: '.$tStamp.'' ,
17 'X-signature: '.$encodedSignature.'',
18 'Content-Type: Application/JSON',
19 'Accept: Application/JSON'
20 );
21
22
23 /**
24 Getting record from API Aplicares
25 */
26 curl_setopt($ch, CURLOPT_URL, "http://dvlp.bpjs-kesehatan.go.id:8888/aplicaresws/rest/bed/read/{YOUR PPK CODE}/1/20");
27 curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
28 curl_setopt($ch, CURLOPT_TIMEOUT, 60);
29 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
30 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
31 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
32 $content = curl_exec($ch);
33 $err = curl_error($ch);
34
35 print_r($err);
36 //print_r($content);
37
38 $data = json_decode($content,true);
39 //print_r($data);
40 //echo "<br><br><br>";
41
42 foreach ($data["response"] as $record) {
43 //print_r($record);
44 }
45
46 $datax = array( 'data' => $record );
47 $superman = json_encode($datax);
48
49 // create or update json file
50 $fp = fopen("list.json", "w");
51 fwrite($fp, $superman);
52 fclose($fp);
53
54 // close cURL resource, and free up system resources
55 curl_close($ch);
56
57?>
58<!DOCTYPE html>
59<html>
60<head>
61<title>View data from BPJS-Aplicares</title>
62<link rel="stylesheet" type="text/css" href="datatables/bootstrap.min.css">
63<link rel="stylesheet" type="text/css" href="datatables/dataTables.bootstrap.css">
64<!--<link rel="stylesheet" type="text/css" href="datatables/jquery.dataTables.css">-->
65</head>
66<body>
67 <table id="list-table" class="table table-striped" cellspacing="0"> <!--table table-striped table-bordered-->
68 <thead>
69 <tr>
70 <th style="width:10px">Tersedia</th>
71 <th style="width:10px">Kode Kelas</th>
72 <th style="width:10px">Nama Kelas</th>
73 <th style="width:10px">Last Update All</th>
74 <th style="width:10px">Tersedia Pria</th>
75 <th style="width:10px">Tersedia Wanita</th>
76 <th style="width:10px">Kode Ruang</th>
77 <th style="width:10px">Kode PPK</th>
78 <th style="width:10px">Tersedia Pria Wanita</th>
79 <th style="width:10px">Nama Ruang</th>
80 <th style="width:10px">Row Number</th>
81 <th style="width:10px">Kapasitas</th>
82 <th style="width:10px">Last Update</th>
83 </tr>
84 </thead>
85 <tbody></tbody>
86 </table>
87
88
89 <script src="jQuery/jQuery-2.1.4.min.js"></script>
90 <script src="datatables/jquery.dataTables.min.js"></script>
91 <script src="datatables/bootstrap.js"></script>
92 <script src="datatables/dataTables.bootstrap.min.js"></script>
93
94 <script type="text/javascript">
95 $(document).ready(function(){
96 $('#list-table').DataTable({
97 "ajax" : "list.json",
98 "columns" : [
99 { "data" : "tersedia" },
100 { "data" : "kodekelas" },
101 { "data" : "namakelas" },
102 { "data" : "lastupdateall" },
103 { "data" : "tersediapria" },
104 { "data" : "tersediawanita" },
105 { "data" : "koderuang" },
106 { "data" : "kodeppk" },
107 { "data" : "tersediapriawanita" },
108 { "data" : "namaruang" },
109 { "data" : "rownumber" },
110 { "data" : "kapasitas" },
111 { "data" : "lastupdate" }
112 ]
113 });
114 });
115 </script>
116
117</body>
118</html>