diff --git a/www-api/app/Config/Routes.php b/www-api/app/Config/Routes.php index 9bcd357b..2aa9a06b 100644 --- a/www-api/app/Config/Routes.php +++ b/www-api/app/Config/Routes.php @@ -71,7 +71,7 @@ $routes->post('/en/wrench/api/v1/startjoblist', 'WrenchApi::apigate'); $routes->get('/en/wrench/api/v1/startjoblist', 'WrenchApi::apigate'); $routes->post('/en/wrench/api/v1/dashdata', 'WrenchApi::apigate'); -$routes->post('/en/wrench/api/v1/getjobsdata', 'WrenchApi::apigate'); //WrenchJobs WrenchApi +$routes->post('/en/wrench/api/v1/getjobsdata', 'WrenchJobs::apigate'); //WrenchJobs WrenchApi $routes->post('/en/wrench/api/v1/offerslist', 'WrenchApi::apigate'); $routes->post('/en/wrench/api/v1/offersresponse', 'WrenchApi::apigate'); diff --git a/www-api/app/Controllers/WrenchJobs.php b/www-api/app/Controllers/WrenchJobs.php index c0c1502f..83f7347c 100644 --- a/www-api/app/Controllers/WrenchJobs.php +++ b/www-api/app/Controllers/WrenchJobs.php @@ -97,9 +97,10 @@ class WrenchJobs extends BaseController if ( $call_backend == true && $in["action"] !='' ){ - // $wrenchboard = new \App\Models\BackendModel(); - $ret = $this->wrenchboard_api($in, $out); - $out['internal_return'] = $ret; + $local_url = "http://10.10.10.120:3033/marketjobs"; + $out = APIcall('GET', $local_url, $in); + // $ret = $this->APIcall($in, $out); + // $out['internal_return'] = $ret; } else { @@ -116,6 +117,40 @@ class WrenchJobs extends BaseController return json_encode( $final_out ); } + + public function APIcall($method, $url, $data) { + // $curl = curl_init(); + $curl = curl_init($url); + switch ($method) { + case "POST": + curl_setopt($curl, CURLOPT_POST, 1); + if ($data) + curl_setopt($curl, CURLOPT_POSTFIELDS, $data); + break; + case "PUT": + curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT"); + if ($data) + curl_setopt($curl, CURLOPT_POSTFIELDS, $data); + break; + } + + curl_setopt($curl, CURLOPT_URL, $url); + curl_setopt($curl, CURLOPT_HTTPHEADER, array( + 'APIKEY: RegisteredAPIkey', + 'Content-Type: application/json', + )); + + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); + $result = curl_exec($curl); + + if(!$result) { + echo("Connection failure!"); + } + curl_close($curl); + return $result; + } + public function wrenchboard_api($in, &$out = array(),$pathWay='') { $ret = 0; $local_url = "http://10.10.10.120:3033/marketjobs";