Advertisement
jamboljack

Cek BPHTB

Nov 19th, 2020
499
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.43 KB | None | 0 0
  1. public function cek_data_bphtb()
  2.     {
  3.         $nop_asli = trim(stripHTMLtags($this->input->post('nop_bphtb', 'true')));
  4.         $nop      = str_replace('.', '', $nop_asli);
  5.         $ntpd     = trim(stripHTMLtags($this->input->post('ntpd', 'true')));
  6.         $dataPost = array('USERNAME' => 'bpn3kabkudus', 'PASSWORD' => 'admin', 'NOP' => $nop, 'NTPD' => $ntpd);
  7.         $curl     = curl_init();
  8.         curl_setopt_array($curl, array(
  9.             CURLOPT_URL            => "https://simbphtb.kuduskab.go.id/simbphtb/h2h_bpn_kudus/Api/getBPHTBService",
  10.             CURLOPT_RETURNTRANSFER => true,
  11.             CURLOPT_ENCODING       => "",
  12.             CURLOPT_MAXREDIRS      => 10,
  13.             CURLOPT_TIMEOUT        => 0,
  14.             CURLOPT_FOLLOWLOCATION => true,
  15.             CURLOPT_HTTP_VERSION   => CURL_HTTP_VERSION_1_1,
  16.             CURLOPT_CUSTOMREQUEST  => "GET",
  17.             CURLOPT_POSTFIELDS     => json_encode($dataPost),
  18.             CURLOPT_HTTPHEADER     => array(
  19.                 "Content-Type: application/json",
  20.                 "Cookie: h2hbpnbphtb=b3t4ig3j21on6b65m4h1jgsa04",
  21.             ),
  22.         ));
  23.  
  24.         $response = curl_exec($curl);
  25.         $err      = curl_error($curl);
  26.         curl_close($curl);
  27.         if ($err) {
  28.             $callback = array('status' => 'errorAPI');
  29.         } else {
  30.             $obj  = json_decode($response, true);
  31.             $code = $obj['respon_code'];
  32.             if ($code == 'OK') {
  33.                 $callback = array(
  34.                     'status'       => 'success',
  35.                     'nop'          => $nop_asli,
  36.                     'ntpd'         => $obj['result']['NTPD'],
  37.                     'nama'         => $obj['result']['NAMA'],
  38.                     'alamat'       => $obj['result']['ALAMAT'] . ' ' . $obj['result']['KELURAHAN_OP'] . ' KEC. ' . $obj['result']['KECAMATAN_OP'],
  39.                     'kota'         => $obj['result']['KOTA_OP'],
  40.                     'luastanah'    => number_format($obj['result']['LUASTANAH'], 0, '', ','),
  41.                     'luasbangun'   => number_format($obj['result']['LUASBANGUNAN'], 0, '', ','),
  42.                     'bayar'        => number_format($obj['result']['PEMBAYARAN'], 0, '', ','),
  43.                     'tanggalbayar' => $obj['result']['TANGGAL_PEMBAYARAN'],
  44.                 );
  45.             } else {
  46.                 $callback = array('status' => 'notfound');
  47.             }
  48.         }
  49.  
  50.         echo json_encode($callback);
  51.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement