· 7 years ago · Dec 04, 2018, 10:26 AM
1<?php
2
3 /*
4$data = "23824";
5 $secretKey = "9tF661A725";
6
7
8 // Computes the timestamp
9 date_default_timezone_set('UTC');
10 $tStamp = strval(time()-strtotime('1970-01-01 00:00:00'));
11 // Computes the signature by hashing the salt with the secret key as the key
12 $signature = hash_hmac('sha256', $data."&".$tStamp, $secretKey, true);
13
14 // base64 encode…
15 $encodedSignature = base64_encode($signature);
16
17 // urlencode…
18 // $encodedSignature = urlencode($encodedSignature);
19
20 // echo "X-cons-id: " .$cons_id ." ";
21 //echo "X-timestamp:" .$tStamp ." ";
22 //echo "X-signature: " .$encodedSignature;
23//$noKartu = $_GET['nokartu'];
24
25//$nik = "3316094602500005";
26$nik = "0000761810848";
27$today = date("Y-m-d");
28
29*/
30
31
32$data = "23824";
33 $secretKey = "9tF661A725";
34 // Computes the timestamp
35 date_default_timezone_set('UTC');
36 $tStamp = strval(time()-strtotime('1970-01-01 00:00:00'));
37 // Computes the signature by hashing the salt with the secret key as the key
38 $signature1 = hash_hmac('sha256', $data."&".$tStamp, $secretKey, true);
39
40 // base64 encode…
41 $encodedSignature = base64_encode($signature1);
42
43 // urlencode…
44 // $encodedSignature = urlencode($encodedSignature);
45
46 echo "X-cons-id: " .$data ." ";
47 echo "X-timestamp:" .$tStamp ." ";
48 echo "X-signature: " .$encodedSignature;
49
50
51echo "<br>";
52
53
54
55
56
57
58
59
60
61//$base_url ="https://dvlp.bpjs-kesehatan.go.id/vclaim-rest";
62
63//$url = "http://dvlp.bpjs-kesehatan.go.id:8080/VClaim-rest/referensi/dokter/pelayanan/2/tglPelayanan/2018-08-17/Spesialis/31486";
64
65
66//$base_url ="http://api.bpjs-kesehatan.go.id:8080/VClaim-rest";
67
68
69
70//$base_url ="http://dvlp.bpjs-kesehatan.go.id:8081/VClaim-rest";
71
72
73$url = 'https://dvlp.bpjs-kesehatan.go.id/vclaim-rest/Peserta/nokartu/0000761810848/tglSEP/2018-11-07';
74//$url = $base_url.'/Peserta/Peserta/nik/'.$nik;
75
76$ch = curl_init($url);
77
78$headers = array(
79
80 "X-cons-id:".$data,
81 "X-timestamp: ".$tStamp,
82 "X-signature: ".$encodedSignature,
83 "Content-Type: application/json; charset=utf-8"
84 );
85//curl_setopt($ch, CURLOPT_URL, $url);
86curl_setopt($ch, CURLOPT_HTTPHEADER,$headers);
87curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
88curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
89curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
90
91
92curl_setopt($ch, CURLOPT_HTTPGET,true);
93$respon = curl_exec($ch);
94
95curl_close($ch);
96
97//$respon = file_get_contents($url);
98
99$json_string = $respon;
100
101$arr = json_decode($json_string,true);
102$pst_metadata = $arr['metaData']['code'];
103
104if($pst_metadata != 200){
105 $nik = $arr['response']['peserta']['noKartu'];
106}
107print_r($respon);
108
109
110?>