heriyadisetiana

update_bed_available_bpjs.php

Jun 18th, 2018
11,487
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.10 KB | None | 0 0
  1. <?php
  2.  
  3.     include "config.php";
  4.  
  5.     // Do query's
  6.     mysqli_query($con, "SET CHARACTER SET utf8");
  7.  
  8.     mysqli_query($con, "SET NAMES 'utf8'");
  9.  
  10.     $query = mysqli_query($con, "SELECT
  11.                              kodekelas,
  12.                              koderuang,
  13.                              namaruang,
  14.                              kapasitas,
  15.                              tersedia
  16.                            FROM bed_available_bpjs");
  17.    
  18.  
  19.     // Start of loop process
  20.     while($row = mysqli_fetch_assoc($query))
  21.     {
  22.         // create record to JSON
  23.         $data = json_encode($row);
  24.  
  25.         // Computes the timestamp
  26.         date_default_timezone_set('UTC');
  27.         $tStamp = strval(time()-strtotime('1970-01-01 00:00:00'));
  28.         // Computes the signature by hashing the salt with the secret key as the key
  29.         $signature = hash_hmac('sha256', $consid."&".$tStamp, $secretKey, true);
  30.         // base64 encode…
  31.         $encodedSignature = base64_encode($signature);
  32.  
  33.         $ch = curl_init();
  34.         $headers = array(
  35.             'X-cons-id: '.$consid .'',
  36.             'X-timestamp: '.$tStamp.'' ,
  37.             'X-signature: '.$encodedSignature.'',
  38.             'Content-Type: Application/JSON',          
  39.             'Accept: Application/JSON'
  40.         );
  41.  
  42.  
  43.         /**
  44.           Sending record to API Aplicares (for UPDATE)
  45.         */          
  46.         curl_setopt($ch, CURLOPT_URL, "http://dvlp.bpjs-kesehatan.go.id:8888/aplicaresws/rest/bed/update/{YOUR PPK CODE}");
  47.         curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  48.         curl_setopt($ch, CURLOPT_TIMEOUT, 60);  
  49.         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  50.         curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
  51.         curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  52.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  53.         $content = curl_exec($ch);
  54.         $err = curl_error($ch);
  55.  
  56.         print_r($err);    
  57.         print_r($content);
  58.  
  59.         // close cURL resource, and free up system resources
  60.         curl_close($ch);      
  61.     }
  62.     // End of loop process
  63.  
  64.  
  65. ?>
Advertisement
Add Comment
Please, Sign In to add comment