· 7 years ago · Mar 26, 2018, 07:38 AM
1<?php
2
3$cons_id = "xxxx";
4 $secretKey = "xxxx";
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', $cons_id."&".$tStamp, $secretKey, true);
10
11 // base64 encode…
12 $encodedSignature = base64_encode($signature);
13
14 // urlencode…
15 // $encodedSignature = urlencode($encodedSignature);
16
17 // echo "X-cons-id: " .$cons_id ." ";
18 // echo "X-timestamp:" .$tStamp ." ";
19 // echo "X-signature: " .$encodedSignature;
20
21
22
23 $headers = array(
24
25 'X-cons-id:'.$cons_id,
26 'X-timestamp: '.$tStamp,
27 'X-signature: '.$encodedSignature,
28 'Content-Type: application/json; charset=utf-8'
29 );
30
31
32 $base_url ="http://dvlp.bpjs-kesehatan.go.id:8081/VClaim-rest";
33
34
35
36
37
38
39$completeurl = $base_url."/referensi/$tipe/".$cari;
40 if($tipe=='poli'){
41 $completeurl = $base_url."/referensi/$tipe/".$cari;
42 }
43
44
45
46$curl = curl_init($completeurl);
47curl_setopt($curl, CURLOPT_HEADER, false);
48curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
49curl_setopt($curl, CURLOPT_HTTPHEADER,
50 array("Accept: application/json; charset=utf-8\r\n" . "X-cons-id: $cons_id\r\n" . "X-Timestamp: $tStamp\r\n" . "X-Signature: $encodedSignature"));
51curl_setopt($curl, CURLOPT_HTTPGET, true);
52#curl_setopt($curl, CURLOPT_POSTFIELDS, $content);
53//curl_setopt($curl, CURLOPT_URL, $url .$nobpjs);
54
55$json_response = curl_exec($curl);
56
57//$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
58
59curl_close($curl);
60
61
62
63 //$response = $this->_send_request($completeurl, $this->generate_hash());
64 $decode = json_decode($json_response, true);
65
66
67
68
69 $decode = json_decode($json_response, true);
70
71
72
73
74
75 $data_referensi = $decode['response'];
76
77 $data = $data_row = array();
78
79 if (is_array($data_referensi)){
80 foreach ($data_referensi[$tipe] as $i => $datapoly ){
81 $arr['query'] = $cari;
82 $arr['suggestions'][] = array(
83 'value' => $datapoly['nama'],
84 'kode' => $datapoly['kode'],
85 );
86
87 }
88 }else{
89 $arr['query'] = $cari;
90 $arr['suggestions'][] = array(
91 'value' => '',
92 'kode' => '',
93 );
94
95 }
96
97 die(json_encode($arr));
98
99 ?>