php_b34st Posted September 19, 2008 Share Posted September 19, 2008 Hi, I am trying to use file_get_contents() but my host does not have allow_url_fopen enabled. Is there an alternative way to grab the data or do I have to get a new host? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/124957-file_get_contents-alternative/ Share on other sites More sharing options...
thebadbad Posted September 19, 2008 Share Posted September 19, 2008 There is cURL, if you've got that installed. Example from the manual comments: <?php function curl_get_file_contents($URL) { $c = curl_init(); curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); curl_setopt($c, CURLOPT_URL, $URL); $contents = curl_exec($c); curl_close($c); if ($contents) return $contents; else return FALSE; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/124957-file_get_contents-alternative/#findComment-645667 Share on other sites More sharing options...
.josh Posted September 19, 2008 Share Posted September 19, 2008 or maybe sockets. Quote Link to comment https://forums.phpfreaks.com/topic/124957-file_get_contents-alternative/#findComment-645669 Share on other sites More sharing options...
php_b34st Posted September 19, 2008 Author Share Posted September 19, 2008 Thanks for the replies, There is cURL, if you've got that installed. Example from the manual comments: I do not think that the host allows curl either. or maybe sockets. Dont sockets use fopen() aswell? Quote Link to comment https://forums.phpfreaks.com/topic/124957-file_get_contents-alternative/#findComment-645692 Share on other sites More sharing options...
.josh Posted September 19, 2008 Share Posted September 19, 2008 well i don't know much about sockets, but I think with sockets, the file is sent to you through the socket and then when you use fopen you are using it locally, so that whole allow_url_fopen shouldn't apply. I could be wrong; as I said, I don't know much about sockets. Quote Link to comment https://forums.phpfreaks.com/topic/124957-file_get_contents-alternative/#findComment-645721 Share on other sites More sharing options...
discomatt Posted September 19, 2008 Share Posted September 19, 2008 http://wiki.dreamhost.com/index.php/Allow_url_fopen might help Quote Link to comment https://forums.phpfreaks.com/topic/124957-file_get_contents-alternative/#findComment-645723 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.