i need to calculate the distance between two area of UK. That's why i use Google Distance Matrix API. In my local host server its works fine, but when i upload it in the internet, its not working. I already get API key from google, verify my website, create a project and add that key in the google. nothing is working for me. Please check my code.
$postcode1=$this->input->post('postcode1');
$postcode2=$this->input->post('postcode2');
$result = array();
$url = "http://maps.googleapis.com/maps/api/distancematrix/json?origins=$postcode1&destinations=$postcode2&mode=driving&language=en-EN&sensor=false&key=MY_API_KEY";
$data = @file_get_contents($url);
$result = json_decode($data, true);
$distance=$result['rows'][0]['elements'][0]['distance']['text'];
echo $distance;