WrenchBanners
This commit is contained in:
@@ -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"];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user