Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File_get_contents not working?

I am using cakephp. I am trying get data from facebook using file_get_contents. I get a warning.

Warning (2): file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration Warning (2): file_get_contents(https://graph.facebook.com/XXXXXXX/?access_token=111978178XXXXXX|2.lg65A3c0atficNsFcf7Rog__.3600.12799XXXX-1000

Is there any way to get the data?

I appreciate any help.

Thanks.

like image 437
Nick Avatar asked Jul 24 '10 09:07

Nick


People also ask

Which is faster curl or file_get_contents?

curl supports HTTPS certificates, HTTP POST, HTTP PUT, FTP uploading HTTP form based upload, proxies, cookies. Curl is a much faster alternative to file_get_contents.

What is the use of file_get_contents () function?

The file_get_contents() reads a file into a string. This function is the preferred way to read the contents of a file into a string. It will use memory mapping techniques, if this is supported by the server, to enhance performance.

What will the file_get_contents () return?

The file_get_contents() function returns Boolean FALSE, but may also return a non-Boolean value which evaluates to FALSE. An E_WARNING level error is generated if filename cannot be found, maxlength is less than zero, or if seeking the specified offset in the stream fails.


1 Answers

This is a configuration issue on your server.

In your php.ini you most probably have

allow_url_fopen = Off

If you want to allow this, set it to on. Be aware though that the reason it's turned off by default is that it's more secure.

A common alternative is to use cURL instead; you might want to check if your hosting environment offers that.

like image 74
kander Avatar answered Sep 27 '22 23:09

kander