· 7 years ago · Jun 18, 2018, 05:30 AM
1<?php
2
3 include "config.php";
4
5 // Do query's
6 mysqli_query($con, "SET CHARACTER SET utf8");
7
8 mysqli_query($con, "SET NAMES 'utf8'");
9
10 $query = mysqli_query($con, "SELECT
11 kodekelas,
12 koderuang
13 FROM bed_available_bpjs");
14
15
16 // Start of loop process
17 while($row = mysqli_fetch_assoc($query))
18 {
19 // create record to JSON
20 $data = json_encode($row);
21
22 // Computes the timestamp
23 date_default_timezone_set('UTC');
24 $tStamp = strval(time()-strtotime('1970-01-01 00:00:00'));
25 // Computes the signature by hashing the salt with the secret key as the key
26 $signature = hash_hmac('sha256', $consid."&".$tStamp, $secretKey, true);
27 // base64 encode…
28 $encodedSignature = base64_encode($signature);
29
30 $ch = curl_init();
31 $headers = array(
32 'X-cons-id: '.$consid .'',
33 'X-timestamp: '.$tStamp.'' ,
34 'X-signature: '.$encodedSignature.'',
35 'Content-Type: Application/JSON',
36 'Accept: Application/JSON'
37 );
38
39
40 /**
41 Sending record to API Aplicares (for DELETE)
42 */
43 curl_setopt($ch, CURLOPT_URL, "http://dvlp.bpjs-kesehatan.go.id:8888/aplicaresws/rest/bed/delete/{YOUR PPK CODE}");
44 curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
45 curl_setopt($ch, CURLOPT_TIMEOUT, 60);
46 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
47 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
48 curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
49 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
50 $content = curl_exec($ch);
51 $err = curl_error($ch);
52
53 print_r($err);
54 print_r($content);
55
56 // close cURL resource, and free up system resources
57 curl_close($ch);
58 }
59 // End of loop process
60
61
62?>