· 7 years ago · Aug 27, 2018, 07:12 AM
1<?php
2 $cons_id = "23824";
3 $secretKey = "9tF661A725";
4 // Computes the timestamp
5 date_default_timezone_set('UTC');
6 $tStamp = strval(time()-strtotime('1970-01-01 00:00:00'));
7 // Computes the signature by hashing the salt with the secret key as the key
8 $signature = hash_hmac('sha256', $cons_id."&".$tStamp, $secretKey, true);
9
10 // base64 encode…
11 $encodedSignature = base64_encode($signature);
12
13 // urlencode…
14 // $encodedSignature = urlencode($encodedSignature);
15
16 // echo "X-cons-id: " .$cons_id ." ";
17 // echo "X-timestamp:" .$tStamp ." ";
18 // echo "X-signature: " .$encodedSignature;
19
20
21
22 $headers = array(
23
24 'X-cons-id:'.$cons_id,
25 'X-timestamp: '.$tStamp,
26 'X-signature: '.$encodedSignature,
27 'Content-Type: application/json; charset=utf-8'
28 );
29
30
31 $base_url ="https://dvlp.bpjs-kesehatan.go.id/vclaim-rest";
32 //$base_url ="http://api.bpjs-kesehatan.go.id:8080/VClaim-rest";
33
34
35 $tipe = $_GET['tipe']; // INI JADI PILIHAN PENCARIAN
36 $cari = $_GET['cari']; // INI GANTI JADI PARAMETER PENCARIAN
37
38
39 // $tipe = 'poli'; // INI JADI PILIHAN PENCARIAN
40 // $cari = 'poli'; // INI GANTI JADI PARAMETER PENCARIAN
41
42//pelayanan/{Parameter 1}/tglPelayanan/{Parameter 2}/Spesialis/{Parameter 3}
43
44//$oompleteurl = $base_url."referensi/dokter/".$cari;
45//$completeurl = $base_url."/referensi/poli/".$cari;
46
47$tglSep = date("Y-m-d");
48
49$completeurl = $base_url."/referensi/dokter/pelayanan/2/tglPelayanan/".$tglSep."/Spesialis/".$cari;
50
51 //$completeurl = $base_url."/referensi/$tipe/".$cari;
52 if($tipe=='dokter'){
53 // $completeurl = $base_url."/referensi/$tipe/".$cari;
54 //$completeurl = $base_url."/referensi/poli/".$cari;
55
56 $completeurl = $base_url."/referensi/dokter/pelayanan/2/tglPelayanan/".$tglSep."/Spesialis/".$cari;
57//$oompleteurl = $base_url."referensi/dokter/".$cari;
58
59 }
60
61
62
63$curl = curl_init($completeurl);
64curl_setopt($curl, CURLOPT_HEADER, false);
65curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
66curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
67curl_setopt($curl, CURLOPT_HTTPHEADER,
68 array("Accept: application/json; charset=utf-8\r\n" . "X-cons-id: $cons_id\r\n" . "X-Timestamp: $tStamp\r\n" . "X-Signature: $encodedSignature"));
69curl_setopt($curl, CURLOPT_HTTPGET, true);
70#curl_setopt($curl, CURLOPT_POSTFIELDS, $content);
71//curl_setopt($curl, CURLOPT_URL, $url .$nobpjs);
72
73$json_response = curl_exec($curl);
74
75//$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
76
77curl_close($curl);
78
79
80
81 //$response = $this->_send_request($completeurl, $this->generate_hash());
82 $decode = json_decode($json_response, true);
83
84
85
86
87 $decode = json_decode($json_response, true);
88
89
90 $data_referensi = $decode['response'];
91
92 $data = $data_row = array();
93
94 if (is_array($data_referensi)){
95 foreach ($data_referensi[$tipe] as $i => $datapoly ){
96 $arr['query'] = $cari;
97 $arr['suggestions'][] = array(
98 'value' => $datapoly['nama'],
99 'kode' => $datapoly['kode'],
100 );
101
102 }
103 }else{
104 $arr['query'] = $cari;
105 $arr['suggestions'][] = array(
106 'value' => '',
107 'kode' => '',
108 );
109
110 }
111
112 die(json_encode($arr));
113
114 ?>