REST Service for POPCORN - ILIAS
alex
2025-06-18 a845b328e326fc8c827ca43fafd43e8c39640275
php/alex.php
@@ -1,20 +1,24 @@
<?php
declare(strict_types=1);
$token = "jkhHKhui899HUKHBzGHtgoiedko2393490";
try {
    # Init ILIAS
    require_once("Services/Init/classes/class.ilInitialisation.php");
    ilInitialisation::initILIAS();
    include_once 'Services/Context/classes/class.ilContext.php';
    ilContext::init(ilContext::CONTEXT_REST);
    #include_once 'Services/Context/classes/class.ilContext.php';
    #ilContext::init(ilContext::CONTEXT_REST);
    header("Content-Type: application/json; charset=UTF-8");
    $method = $_SERVER['REQUEST_METHOD'];
    $curtoken = $_GET["token"];
    $command = $_GET["command"];
    $obj_id = (int) $_GET["obj_id"];
    $dry = $_GET["dry"]; # "0" = false, "1" = true
    $res = array(
        "method" => $method,
@@ -23,6 +27,16 @@
        "status" => null,
        "msg" => null
    );
    // check token
    if($token !== $curtoken) {
        http_response_code(403);
        $res["status"] = "error";
        $res["msg"] = "access denied";
        $json = json_encode($res, JSON_PRETTY_PRINT);
        echo $json;
        die(); // this ends here
    }
    try {
        switch ($command) {
@@ -92,3 +106,4 @@
}
?>