"Unauthorized")); exit(); } $database = new Database(); $db = $database->getConnection(); $data = json_decode(file_get_contents("php://input")); if (!empty($data->id) && !empty($data->latitude) && !empty($data->longitude)) { try { $query = "UPDATE spbu SET latitude = :latitude, longitude = :longitude WHERE id = :id"; $stmt = $db->prepare($query); $stmt->bindParam(":latitude", $data->latitude); $stmt->bindParam(":longitude", $data->longitude); $stmt->bindParam(":id", $data->id); if ($stmt->execute()) { http_response_code(200); echo json_encode(array("message" => "Posisi SPBU berhasil diupdate")); } else { http_response_code(503); echo json_encode(array("message" => "Gagal mengupdate posisi")); } } catch(PDOException $e) { http_response_code(500); echo json_encode(array("message" => "Error: " . $e->getMessage())); } } else { http_response_code(400); echo json_encode(array("message" => "Data tidak lengkap")); } ?>