· 6 years ago · Jul 25, 2019, 07:24 AM
1$client = new GuzzleHttp\Client(
2 ['base_uri' => 'https://dvlp.bpjs-kesehatan.go.id/vclaim-rest/']
3 );
4
5 $consid = '0090R039';
6 $secretKey = "9wN010E65A";
7
8 date_default_timezone_set('UTC');
9 $tStamp = strval(time() - strtotime('1970-01-01 00:00:00'));
10
11 // Computes the signature by hashing the salt with the secret key as the key
12 $signature = hash_hmac('sha256', $consid . "&" . $tStamp, $secretKey, true);
13 // base64 encode…
14 $encodedSignature = base64_encode($signature);
15
16 $response = $client->request('GET', '', [
17 'headers' => [
18 'X-cons-id' => $consid,
19 'X-timestamp' => $tStamp,
20 'X-signature' => $encodedSignature,
21 'ContentType' => 'application/json',
22 'Accept' => 'application/json',
23 ],
24 // 'parameter' => '0090R0391218V002993',
25 ]);
26 $code = $response->getStatusCode(); // 200
27 $reason = $response->getReasonPhrase(); // OK
28 // echo $code;
29 $response = json_decode($response->getBody()->getContents());
30 echo '<pre>';
31 print_r($response->response->list);
32 echo '</pre>';