--- a/tripPlanner.php +++ b/tripPlanner.php @@ -1,8 +1,8 @@ $errorMessage"; echo '
@@ -61,6 +62,7 @@ echo '
  • '; processLeg($legNumber, $leg); echo "
  • "; + flush(); @ob_flush(); } echo ""; } @@ -111,27 +113,36 @@ $fromPlace = (startsWith($from, "-") ? $from : geocode($from, false)); if ($toPlace == "" || $fromPlace == "") { $errorMessage = ""; - if ($toPlace === "") $errorMessage.= urlencode($to) . " not found.
    \n"; - if ($fromPlace === "") $errorMessage.= urlencode($from) . " not found.
    \n"; + if ($toPlace === "") { + $errorMessage.= urlencode($to) . " not found.
    \n"; + trackEvent("Trip Planner","Geocoder Failed", $to); + } + if ($fromPlace === "") { + $errorMessage.= urlencode($from) . " not found.
    \n"; + trackEvent("Trip Planner","Geocoder Failed", $from); + } tripPlanForm($errorMessage); } else { $url = $otpAPIurl . "ws/plan?date=" . urlencode($_REQUEST['date']) . "&time=" . urlencode($_REQUEST['time']) . "&mode=TRANSIT%2CWALK&optimize=QUICK&maxWalkDistance=840&wheelchair=false&toPlace=$toPlace&fromPlace=$fromPlace&intermediatePlaces="; - $ch = curl_init($url); + debug($url); + $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_HTTPHEADER, array( "Accept: application/json" )); - curl_setopt($ch, CURLOPT_TIMEOUT, 5); + curl_setopt($ch, CURLOPT_TIMEOUT, 10); $page = curl_exec($ch); - if (curl_errno($ch)) { - tripPlanForm("Trip planner temporarily unavailable: " . curl_errno($ch) . " " . curl_error($ch) .(isDebug() ? $url : "")); - + if (curl_errno($ch) || curl_getinfo($ch, CURLINFO_HTTP_CODE) != 200) { + tripPlanForm("Trip planner temporarily unavailable: " . curl_errno($ch) . " " . curl_error($ch) . " ". curl_getinfo($ch, CURLINFO_HTTP_CODE) .(isDebug() ? "
    ".$url : "")); + trackEvent("Trip Planner","Trip Planner Failed", $url); } else { + trackEvent("Trip Planner","Plan Trip From", $from); + trackEvent("Trip Planner","Plan Trip To", $to); $tripplan = json_decode($page); - debug(print_r($triplan, true)); + debug(print_r($tripplan, true)); echo "

    From: {$tripplan->plan->from->name} To: {$tripplan->plan->to->name}

    "; echo "

    At: ".formatTime($tripplan->plan->date)."

    "; if (is_array($tripplan->plan->itineraries->itinerary)) {