47 lines
1.0 KiB
PHP
47 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Utility;
|
|
|
|
class CurlRequest {
|
|
|
|
|
|
|
|
public function makeCurlRequest($params,$method,$URL,$header = ['Content-Type: application/json']){
|
|
$ch = curl_init();
|
|
if ($this->isNonSecureConnection()){
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
|
}
|
|
curl_setopt($ch, CURLOPT_URL, $URL);
|
|
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
|
|
|
|
if(!empty($header)){
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
|
|
}
|
|
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
curl_setopt($ch, CURLOPT_TIMEOUT, 900);
|
|
$output = curl_exec($ch);
|
|
curl_close($ch);
|
|
return $output;
|
|
}
|
|
|
|
private function isNonSecureConnection(){
|
|
|
|
$host = $_SERVER['REMOTE_ADDR'];
|
|
$result = true;
|
|
|
|
/*if ($host != 'readytogoletters.com') {
|
|
|
|
$result = true;
|
|
|
|
}*/
|
|
|
|
return $result;
|
|
}
|
|
|
|
|
|
|
|
}
|