Привет, я получаю следующую ошибку в моей домашней работе, и я не знаю, в чем проблема hasildata.php в строке 21:
$dataJson = file_get_contents("https://maps.googleapis.com/maps/api/distancematrix/json?units=metric&origins=".$from."&destinations=".$to."&key=%20AIzaSyCWpwVwu1hO6TJW1H8x_zlhrLfbSbQ2r3o"); $data = json_decode($dataJson,true); $nilaiJarak = $data['rows'][0]['elements'][0]['distance']['text']; $time=$data['rows'][0]['elements'][0]['duration']['text'];
Снимок экрана
Вы должны проверить, в порядке ли ваш запрос
$dataJson = file_get_contents("https://maps.googleapis.com/maps/api/distancematrix/json?units=metric&origins=".$from."&destinations=".$to."&key=%20AIzaSyCWpwVwu1hO6TJW1H8x_zlhrLfbSbQ2r3o"); $data = json_decode($dataJson,true); if ($data['status'] !== "OK") { // Error echo $data['error_message']; // Do something } else { $nilaiJarak = $data['rows'][0]['elements'][0]['distance']['text']; $time=$data['rows'][0]['elements'][0]['duration']['text']; }