Advertisement
jamboljack

BPHTB

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