I took this code from stackoverflow to calculate address :
$from = urlencode($from);
$to = urlencode($to.', Челябинс');
$data = file_get_contents('http://maps.googleapis.com/maps/api/distancematrix/json?origins='.$from.'&destinations='.$to.'&language=ru-RU&sensor=false&mode=driving');//&key=AIzaSyDAJ05io1966D_KmF7lbRsucehr8GtUBqk');
$data = json_decode($data);
$time = 0;
$distance = 0;
foreach($data->rows[0]->elements as $road) {
$time += $road->duration->value;
$distance += $road->distance->value;
}
$table[0]=$distance;
$table[1]=$time;
It is working very good once I have the file on my computer. But when I put it online, it is not working anymore.
Somebody would have an idea of what could go wrong with it? I also read that for APIs we need a key, but in my case it is from a HTML/PHP website I want to use it.
Thanks in advance for your help
Edit :
Could find a good post about this issue :
[Why doesn't file_get_contents work?
In fact the problem is(if I understood correct) due to a parameter of server, I get the following message :
Warning: file_get_contents(): http:// wrapper is disabled in the server configuration by allow_url_fopen=0
Is this a parameter we can modify ourself?or do we have to ask web hoster to modify it?