phayes/geoPHP — Issue #6: Google Geocode without file_get_contents callback
Author: fillerwriter
Created: 2011-10-19 15:40:12+00:00
State: open

From a comment on a Drupal Geofield issue (http://drupal.org/node/1234496)

> The module uses $this->result = json_decode(@file_get_contents($url)); (line 49 of GoogleGeocode.class.php) to actually send the request to Google and get the response. However, the file_get_contents operation will only work if 'allow_url_fopen' is on in the PHP configuration. If 'allow_url_fopen' is not allowed, then the 'file_get_contents' will not be allowed to execute, but the '@' sign suppresses error reporting. A lot of hosting providers rightly consider allow_url_fopen to be a security risk, so it's not really ideal. But this is in the geoPHP library, so I guess an issue should be filed with that project rather than here on Drupal.org.

> In any case, in the Apache configuration, I added this line, which made the thing work: php_admin_flag allow_url_fopen on

> Drupal uses 'drupal_http_request()' these days for those sorts of operations. It would be good if the geoPHP library could use something similar instead of 'allow_url_fopen'.

I'm not sure how to address this without either duplicating code or forcing some weird dependencies. It might be worth just saying that you need to have file_get_contents enabled on your server.