Advertisement
jamboljack

Cek PBB

Nov 19th, 2020
347
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.23 KB | None | 0 0
  1. public function cek_data_pbb()
  2.     {
  3.         $nop_asli = trim(stripHTMLtags($this->input->post('nop_pbb', 'true')));
  4.         $nop      = str_replace('.', '', $nop_asli);
  5.         $curl     = curl_init();
  6.         $dataPost = array('NOP' => $nop);
  7.         curl_setopt_array($curl, array(
  8.             CURLOPT_URL            => "https://simbphtb.kuduskab.go.id/simbphtb/h2h_bpn_kudus/Api/getPBBServiceJamak",
  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  => "GET",
  16.             CURLOPT_POSTFIELDS     => json_encode($dataPost),
  17.             CURLOPT_HTTPHEADER     => array(
  18.                 "Content-Type: application/json",
  19.                 "Cookie: h2hbpnbphtb=7psu72g6a12elj6tvkf2594qn4",
  20.             ),
  21.         ));
  22.  
  23.         $response = curl_exec($curl);
  24.         $err      = curl_error($curl);
  25.         curl_close($curl);
  26.         if ($err) {
  27.             $callback = array('status' => 'errorAPI');
  28.         } else {
  29.             $obj = json_decode($response, true);
  30.             $jml = count($obj['ITEM']);
  31.             if ($jml > 0) {
  32.                 $callback = array(
  33.                     'status'        => 'success',
  34.                     'nop'           => $nop_asli,
  35.                     'nama'          => $obj['NAMA_WP'],
  36.                     'alamat'        => $obj['ALAMAT_OP'] . ' ' . $obj['KELURAHAN_OP'] . ' KEC. ' . $obj['KECAMATAN_OP'],
  37.                     'kota'          => $obj['KOTA_OP'],
  38.                     'luastanah'     => number_format($obj['LUASTANAH_OP'], 0, '', ','),
  39.                     'luasbangun'    => number_format($obj['LUASBANGUNAN_OP'], 0, '', ','),
  40.                     'njop_tanah'    => number_format($obj['NJOP_TANAH_OP'], 0, '', ','),
  41.                     'njop_bangunan' => number_format($obj['NJOP_BANGUNAN_OP'], 0, '', ','),
  42.                     'item'          => $obj['ITEM'],
  43.                 );
  44.             } else {
  45.                 $callback = array('status' => 'notfound');
  46.             }
  47.         }
  48.  
  49.         echo json_encode($callback);
  50.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement