module); } public function index_get() { //$this->api_login("meninjar@simrs", "dibawahmejasaya"); $this->api_connect("pasien", "Y1hLd2tUeTdBSGt6c05sOWxoWmVwV1B6SllkYVhZaHBlTXpJZWNxUw==", "10026543"); exit; //$data = $this->db->get('master_user')->result(); $array_query = [ 'select' => 'master_user.*', 'from' => 'master_user', 'order_by' => 'master_user.mu_id, ASC' ]; $get_all_data = Modules::run('database/get', $array_query)->result(); $get_data = Modules::run('database/get', ['from' => 'master_user', 'order_by' => 'mu_id'])->result(); //$data = 'Data Berhasil Load Data'; $this->response($get_data, RestController::HTTP_OK); } public function login_post() { $request = $this->post(); $response = null; $method = $this->_detect_method(); try { $username = isset($request['username']) ? $request['username'] : ''; $password = isset($request['password']) ? $request['password'] : ''; if ($username == "" || $password == "") { $response = response_error("Username dan password harus diisi"); $this->set_response($response, RestController::HTTP_BAD_REQUEST); return; } $where = array( "username" => $username ); $user_data = $this->m_common->get('user', $where)->row(); $response = response_error("Username atau password salah"); if (isset($user_data)) { $is_password_valid = verify_password($password, $user_data->password); unset($user_data->password); if ($is_password_valid) $response = response_success(); } if (!$response['success']) { $this->set_response($response, RestController::HTTP_UNAUTHORIZED); return; } $response = response_success("Login berhasil"); $this->set_response($response, RestController::HTTP_OK); } catch (Exception $ex) { $response = response_error($ex->getMessage()); // $this->set_response($response, RestController::HTTP_INTERNAL_SERVER_ERROR); } } public function api_connect($param, $token, $value) { //$url = "http://10.10.123.63:9000/api/pasien/10026543"; $url = "http://10.10.123.63:9000/api/" . $param . "/" . $value; //print_r($url); $authorization = "x-token:" . $token; $ch = curl_init(); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => [$authorization], CURLOPT_URL => $url ]); $return = curl_exec($ch); $result = array(); $api_array = json_decode($return, TRUE); print_r($api_array); return $result; } public function api_login($username, $password) { // http://10.10.123.63:9000/api/login?email=ragil@simrs&password=gantenggantengserigala2022 $url = "http://10.10.123.63:9000/api/login?email=" . $username . "&password=" . $password; $ch = curl_init(); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_URL => $url ]); $return = curl_exec($ch); $result = array(); $api_array = json_decode($return, TRUE); print_r($api_array); //print_r($api_array['code']); /*if ($api_array['code'] == '200') { $result['status'] = TRUE; $result['content'] = $api_array['content']; } else { $result['status'] = FALSE; $result['content'] = "connect api failed, try again"; }*/ } }