db_onedev = $this->load->database("nasional", true); } function send() { try { $prm = $this->sys_input; $url="http://".$prm['Nat_RegionalIP']."/one-api/nasacom/downloadcheckcompany/checkcompany"; $data = array("code" => $prm['Nat_CompanyNumber']); //echo $url; $ch = curl_init( $url ); # Setup request to send json via POST. $payload = json_encode( $data ); curl_setopt( $ch, CURLOPT_POSTFIELDS, $payload ); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen($payload)) ); # Return response instead of printing. curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); # Send request. $result = curl_exec($ch); curl_close($ch); # Print response. $array_rst = $this->objToArray(json_decode($result)); //print_r($result); if($array_rst['status'] == 'OK'){ $result = array( "status" => true); $this->sys_ok($result); } else{ $result = array( "status" => false); $this->sys_ok($result); } } catch (Exception $exc) { $message = $exc->getMessage(); $this->sys_error($message); } } protected function objToArray($obj) { // Not an object or array if (!is_object($obj) && !is_array($obj)) { return $obj; } // Parse array foreach ($obj as $key => $value) { $arr[$key] = $this->objToArray($value); } // Return parsed array return $arr; } }