Example #1
0
/**
    Функция валидирует JSON
*/
function isValidJSON($json)
{
    if (!isset($json)) {
        getResultJSON(array("status" => "ERROR", "status_msg" => "NO DATA"));
        return false;
    }
    if (!is_array($json)) {
        getResultJSON(array("status" => "ERROR", "status_msg" => "Некорректные данные - не массив"));
        return false;
    }
    if (empty($json)) {
        getResultJSON(array("status" => "ERROR", "status_msg" => "Некорректные данные - пустой массив"));
        return false;
    }
    return true;
}
Example #2
0
"/>
(i.e. 0.95)<br/>
</p><p>
<input type='submit' name='get' value="Get Result">
<input type='submit' name='set' value="Set Result">
</form>
<?php 
$postBody = false;
$content_type = "application/vnd.ims.lis.v2.result+json";
if (isset($_REQUEST['get'])) {
    $response = sendOAuthGET($result_url, $oauth_consumer_key, $oauth_consumer_secret, "application/vnd.ims.lis.v2.result+json");
    $debugin = get_get_sent_debug();
    $debugout = get_get_received_debug();
} else {
    if (isset($_REQUEST['set'])) {
        $addStructureRequest = getResultJSON($_REQUEST['grade'], $_REQUEST['comment']);
        $postBody = indent(json_encode($addStructureRequest));
        $response = sendOAuthBody("PUT", $result_url, $oauth_consumer_key, $oauth_consumer_secret, $content_type, $postBody);
        $debugin = get_body_sent_debug();
        $debugout = get_body_received_debug();
    } else {
        exit;
    }
}
global $LastOAuthBodyBaseString;
$lbs = $LastOAuthBodyBaseString;
ltiUtilTogglePre("Headers sent", $debugin);
if ($postBody !== false) {
    ltiUtilTogglePre("Our Body Data", indent($postBody));
}
ltiUtilTogglePre("Our Base String", $lbs);