$url = "https://www.google.com";
$defaults = array(
CURLOPT_URL => $url,
CURLOPT_HEADER => 0,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_HTTPHEADER => array('Content-Type: application/json'),
);
try{
$ch = curl_init();
curl_setopt_array($ch, $defaults);
$result = curl_exec($ch);
} catch(Exception $e){
echo 'Error: ' . $e->getMessage();die;
}
if(curl_errno($ch)){
echo 'Error: ' . curl_error($ch);die;
}
if(!$result)
{
trigger_error(curl_error($ch));
}
// In case if response data is json encoded
$decoded_response = json_decode($result,true);
echo "<pre>";print_r($decoded_response);echo "</pre>";exit;
curl_close($ch);