cURL alternativa a file_get_contents
Para todos aquellos que no pueden utilizar la función file_get_contents en su hosting por temas de seguridad, aquí dejo una función alternativa que hace lo mismo.
public function file_get_contents_curl($url) {
$ch = curl_init();curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Set curl to return the data instead of printing it to the browser.
curl_setopt($ch, CURLOPT_URL, $url);$data = curl_exec($ch);
curl_close($ch);return $data;
}
Como se puede observar, se ha utilizado cURL. Es decir, tiene que estar habilitado cURL para que se pueda utilizar
