Help with fopen to curl change

I have purchased a wordpress theme however I am having issues with it because my hosting company don’t support the use of the fopen command, however I am an extreme noobie and am not sure how to change this code to use curl instead.

function parseFonts(){
// Open the text file and get the content
$filename = get_template_directory_uri()."/fonts/google_fonts.txt";
$handle = fopen($filename, ‘r’);
$readedData = stream_get_contents($handle);//fread($handle, filesize($filename));
$fontsArr = explode("\n", $readedData);
fclose($handle);

return $fontsArr;

}

Any help would be greatly appreciated

sorry since posting I have sort of found a work around by doing this

function parseFonts(){
// Open the text file and get the content
$c = curl_init(get_template_directory_uri()."/fonts/google_fonts.txt");
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
$filename = get_template_directory_uri()."/fonts/google_fonts.txt";
$handle = curl_exec($c);
curl_close($c);
$readedData = stream_get_contents($handle);//fread($handle, filesize($filename));
$fontsArr = explode("\n", $readedData);
return $fontsArr;
}

I keep getting this error stream_get_contents() expects parameter 1 to be resource, string given in FILENAME Line 193 which refers to this line

$readedData = stream_get_contents($handle);//fread($handle, filesize($filename));

All my Google shows I should enable fopen which I have already established I cannot.

It would help me a great deal if someone could look over the code and advise what I need to change to make it work without the error

Sponsor our Newsletter | Privacy Policy | Terms of Service