· 7 years ago · Mar 23, 2018, 11:40 AM
1<?php
2$cons_id = "xxxx";
3 $secretKey = "xxxxx";
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 ="http://dvlp.bpjs-kesehatan.go.id:8081/VClaim-rest";
32
33//$url = $base_url.'/Peserta/nik/'.$nik.'/tglSEP/'.$tgl;
34
35$poli = $_GET['nama'];
36//$poli = 'ANA';
37
38
39$url = $base_url.'/referensi/poli/'.$poli;
40//$url = $base_url.'/Referensi/getPoli';
41
42$curl = curl_init($url);
43curl_setopt($curl, CURLOPT_HEADER, false);
44curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
45curl_setopt($curl, CURLOPT_HTTPHEADER,
46 array("Accept: application/json; charset=utf-8\r\n" . "X-cons-id: $cons_id\r\n" . "X-Timestamp: $tStamp\r\n" . "X-Signature: $encodedSignature"));
47curl_setopt($curl, CURLOPT_HTTPGET, true);
48#curl_setopt($curl, CURLOPT_POSTFIELDS, $content);
49//curl_setopt($curl, CURLOPT_URL, $url .$nobpjs);
50
51$data = curl_exec($curl);
52
53//$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
54
55curl_close($curl);
56
57
58
59echo $data;
60
61//var_dump($status);
62
63/*$arr = json_decode($json_response, true);
64
65
66$pst_metadata = $arr['metaData']['code'];
67
68if($pst_metadata == 200){
69$nik = $arr['response']['poli'];
70
71}
72
73//print_r($json_response['response']['poli'];);
74
75print_r($json_response);
76
77*/
78?>