It is not safe to turn on allow_url_fopen in php.ini due to various security reasons . You should use curl instead of file_get_contents . So if allow_url_fopen is turned off on your server you can use the below method to acheive the same target
function file_get_contents_curl($url) {
curl_setopt($ch=curl_init(), CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
Comment below if it helps 🙂
(Visited 150 times, 1 visits today)