12 November 2019

PHP - vclaim BPJS Bridging

sumber :
https://dvlp.bpjs-kesehatan.go.id/vclaim-katalog

baca dulu bagian HELP, pastikan sudah mempunyai consid dan secretkey test

OS Linux, Apache2, Php, Curl


contoh dari https://dvlp.bpjs-kesehatan.go.id/VClaim-Katalog/Peserta berdasarkan No Kartu Kepesertaan BPJS.



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php

$consid = "12345";
$secretKey = "0123456789";

date_default_timezone_set('UTC');

$tStamp = strval(time()-strtotime('1970-01-01 00:00:00'));
$signature = hash_hmac('sha256', $consid."&".$tStamp, $secretKey, true);
$encodedSignature = base64_encode($signature);
$urlencodedSignature = urlencode($encodedSignature);


echo "X-cons-id: " .$consid ."";
echo "X-timestamp:" .$tStamp ."";
echo "X-signature: " .$encodedSignature;


$headers=array(
        'X-cons-id:'.$consid.'',
        'X-timestamp:'.$tStamp.'',
        'X-signature:'.$encodedSignature.'',
        'Content-Type:application/json'
        );


$ch=curl_init();
curl_setopt($ch,CURLOPT_URL,"https://dvlp.bpjs-kesehatan.go.id/Vclaim-rest/Peserta/nokartu/0001844935777/tglSEP/2017-11-07");
curl_setopt($ch,CURLOPT_HTTPHEADER,$headers);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_TIMEOUT,3);
curl_setopt($ch,CURLOPT_HTTPGET,1);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);

$content=curl_exec($ch);

curl_close($ch);

$data=json_decode($content, true);

print_r($data);


echo "<br>";
echo count($data);
echo "<br>";
echo $data["response"]["peserta"]["nama"];
echo "<br>";
echo $data["response"]["peserta"]["hakKelas"]["keterangan"];
echo "<br>";
?>

No comments: