Alternative to allow_url_fopen using xml and geolocation

Asked

Viewed 36 times

0

Meta:

  • User type an address and I must recover it by means of geolocation.

Problem:

  • The code below works locally and returns the latitude and longitude value. However, I need it to work on the server. From what I read I need to enable allow_url_fopen and allow_url_include in a php.ini. According to the staff of Locaweb (where I host the site) I will only have access to these instructions if you change your hosting plan, which is currently not feasible.

Can you think of an alternative so I can retrieve that information?

<?php

$rua = "Av. Belo Horizonte";
$numero = "122";
$bairro = "Belo Horizonte";

$xml_link = 'https://maps.googleapis.com/maps/api/geocode/xml?address=Monte Carmelo, Minas Gerais,' . $rua . ',Numero ' . $numero . ',Bairro ' . $bairro . '&key=API-KEY'; 
$xml=simplexml_load_file($xml_link);

$latitude = $xml->result->geometry->location->lat;
$longitude = $xml->result->geometry->location->lng;

echo gettype($latitude);

echo($latitude . ", " . $longitude);

?>

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.