just to extend Shankars and amals answers with simple unit testing:
/**
*
* workaround HTTPS problems with file_get_contents
*
* @param $url
* @return boolean|string
*/
function curl_get_contents($url)
{
$data = FALSE;
if (filter_var($url, FILTER_VALIDATE_URL))
{
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
$data = curl_exec($ch);
curl_close($ch);
}
return $data;
}
// then in the unit tests:
public function test_curl_get_contents()
{
$this->assertFalse(curl_get_contents(NULL));
$this->assertFalse(curl_get_contents('foo'));
$this->assertTrue(strlen(curl_get_contents('https://www.google.com')) > 0);
}