Beispiel #1
0
$filterObj = new trails();
$filterResult = $filterObj->filterByLocation("city", "Albuquerque", 0, 6, "Array");
echo json_encode($filterResult, JSON_PRETTY_PRINT);
?>

                    </pre>
                    
                    <h3>Translations</h3>                    
                    <p>Notice that the JSON response for trail requests includes available translations under the key <code>translations</code>. In the request illustrated above, Spanish (es) is listed as an available translation. In order to retrieve this translation, we will send a <code>GET</code> request: <code>GET <?php 
echo $baseurl;
?>
api/translation/?id=2&lang=es</code></p>
                    <pre>

	<?php 
echo json_encode($GetTrail->getTranslation("es", "Array"), JSON_PRETTY_PRINT);
?>

                    </pre>

                	<h3>Website Source Code</h3>                   
                    <p>The source code for this website is available for use under the <a class="green-text text-darken-3" rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>. It is available at this <a href="https://github.com/jmayfiel/prescriptiontrails">GitHub repository</a>.</p>

                	<h3>Questions?</h3>                   
                    <p>Feel free to <a href="<?php 
echo $baseurl;
?>
about/contact/">contact us</a> with any questions.</p> 
                                    
                </div>
              
Beispiel #2
0
    $error_details = "The trail ID should be an integer. '" . htmlspecialchars($_GET['id']) . "' is an invalid id value.";
}
if (!$error) {
    $trailObj = new trail();
    $trailObj->setID(intval($_GET['id']));
    $trail = $trailObj->getInfo("Array");
    if ($trail == "Etrail") {
        //ERROR - Trail does not exist
        $error = true;
        $error_type = "unknown_id";
        $error_details = "The trail ID '" . htmlspecialchars($_GET['id']) . "' was not found in our database. It may have been deleted from our system. Please contact us if you have any questions or concerns.";
    } else {
        $update = false;
        if (in_array($lang, $trail['translations'])) {
            $update = true;
            $translation = $trailObj->getTranslation($lang, "Array");
        }
    }
}
if (!$error) {
    ini_set('display_errors', 1);
    ini_set('display_startup_errors', 0);
    error_reporting(E_ERROR | E_PARSE);
    if ($trail['loopcount'] == 1) {
        $looptext = "one loop";
        $distance = $trail['loops'][1]['distance'];
        $steps = $trail['loops'][1]['steps'];
    } else {
        $looptext = $trail['loopcount'] . " loops";
        $distance = 0;
        $steps = 0;
Beispiel #3
0
    echo json_encode($response);
    exit;
}
if (!is_numeric($_GET['id']) && $error === false) {
    $response = array("status" => "error", "type" => "INVALID_ID", "message" => "The trail ID should be an integer. '" . htmlspecialchars($_GET['id']) . "' is an invalid id value. See " . $baseurl . "api/");
    echo json_encode($response);
    exit;
}
if (!isset($_GET['lang']) || empty($_GET['lang'])) {
    $response = array("status" => "error", "type" => "MISSING_LANG", "message" => "The language was not provided in the request. See " . $baseurl . "api/");
    echo json_encode($response);
    exit;
}
$trailObj = new trail();
$trailObj->setID(intval($_GET['id']));
$trail = $trailObj->getInfo("Array");
if ($trail == "Etrail") {
    $response = array("status" => "error", "type" => "UNKNOWN_ID", "message" => "The trail ID '" . htmlspecialchars($_GET['id']) . "' was not found in our database. It may have been deleted from our system. Please contact us if you have any questions or concerns. See " . $baseurl . "api/");
    echo json_encode($response);
    exit;
} else {
    $looptranslation = false;
    if (in_array($_GET['lang'], $trail['translations'])) {
        $translation = $trailObj->getTranslation($lang_set, "JSON");
        echo $translation;
    } else {
        $response = array("status" => "error", "type" => "TRANSLATION_UNAVAILABLE", "message" => "The trail ID '" . htmlspecialchars($_GET['id']) . "' does not have a translation that matches '" . htmlspecialchars($_GET['lang']) . "'. See " . $baseurl . "api/");
        echo json_encode($response);
        exit;
    }
}