WrenchBanners

This commit is contained in:
CHIEFSOFT\ameye
2024-02-24 20:49:01 -05:00
parent 3b970663a7
commit e47c94cf25
3 changed files with 184 additions and 60 deletions
+32 -60
View File
@@ -117,67 +117,39 @@ class WrenchJobs extends BaseController
}
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;
}
// 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 json_decode($result, true);
// }
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 json_decode($result, true);
}
public function wrenchboard_api($in, &$out = array(),$pathWay='') {
$ret = 0;
$local_url = "http://10.10.10.120:3033/marketjobs";
$url = $local_url ; // ."/".$urlPath; //"/generics";
$data = $in;
//$content = json_encode($data);
$content = urlencode($data);
$curl = curl_init($url);
curl_setopt($ch, CURLOPT_URL,$content);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-type" => "application/json"));
// curl_setopt($curl, CURLOPT_POST, true); // true to make POST
// curl_setopt($curl, CURLOPT_POSTFIELDS, $content);
$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ($status != 200) {
echo ("Error: call to URL $url failed with status $status, response $json_response, | curl_error " . curl_error($curl) . ", | curl_errno " . curl_errno($curl));
}
curl_close($curl);
$response = json_decode($json_response, true);
$out = $response;
return $response["internal_return"];
}
}