Lamhot / php-google-map-api

Automatically exported from code.google.com/p/php-google-map-api
0 stars 0 forks source link

extend fetchURL() if allow_url_fopen=off #11

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
some ext. hoster set allow_url_fopen=off so file_get_contents($url) isn't 
working. instead of let the user override these func add something simply like

    function fetchURL($url) {
        if (ini_get('allow_url_fopen')) {
            return file_get_contents($url);
        } elseif (function_exists('curl_init')) {
            $curlObj = curl_init($url);
            curl_setopt($curlObj, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($curlObj, CURLOPT_HEADER, 0);
            $content = curl_exec($curlObj);
            curl_close($curlObj);
            return $content;
        } else {
            die('Error');
        } 
    }

Original issue reported on code.google.com by manuel.w...@gmail.com on 19 Jul 2010 at 12:32

GoogleCodeExporter commented 9 years ago
Most shared webhosting services disable file_get_contents(). Please use the 
CURL method.

Thanks.

Original comment by machad...@gmail.com on 29 Jul 2010 at 10:29

GoogleCodeExporter commented 9 years ago

Original comment by b...@mycnl.com on 25 Sep 2011 at 3:17