add rssa-pintar to git
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
class Apiconection extends CI_Controller{
|
||||
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";
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user