Example #1
0
File: index.php Project: K-atc/Kch
}
// -------
// APIの実行
// -------
switch ($api) {
    case LOAD_THREAD:
        $json = Kch::load($thread);
        if ($json === Null) {
            Kch::throw_404();
            $res = array("status" => "ERROR", "message" => "thread not found");
        } else {
            $res = array("status" => "OK", "result" => $json);
        }
        break;
    case POST_CONTRIBUTION:
        $bool = Kch::save($thread, $contribution);
        if ($bool === false) {
            $res = array("status" => "ERROR", "message" => "post error");
        } else {
            $json = Kch::load($thread);
            if ($json === Null) {
                Kch::throw_404();
                $res = array("status" => "ERROR", "message" => "thread not found");
            } else {
                $res = array("status" => "OK", "result" => $json);
            }
        }
        break;
    case API_PARAM_ERROR:
        Kch::throw_404();
        $res = array("status" => "ERROR", "message" => "parameter error");