Пример #1
0
                            header($_SERVER["SERVER_PROTOCOL"] . " 404 Not Found");
                            $this->sendJson(array('error' => true));
                        } else {
                            if (isset($ret['__raw']) && $ret['__raw']) {
                                unset($ret['__raw']);
                                $this->sendJson($ret);
                            }
                            $this->sendJson(array('error' => false, 'data' => $ret));
                        }
                    }
                    header($_SERVER["SERVER_PROTOCOL"] . " 405 Method Not Allowed");
                    $this->sendJson(array('error' => true, 'message' => '405 Method Not Allowed'));
                }
            }
            header($_SERVER["SERVER_PROTOCOL"] . " 404 Not Found");
            $this->sendJson(array('error' => true, 'message' => '404 Not Found'));
        }
        echo "Restfull API 1.0";
    }
}
//create api instance
$a = str_replace('\\', '/', realpath($_SERVER['SCRIPT_FILENAME']));
$b = str_replace('\\', '/', realpath(__FILE__));
if ($a === $b) {
    //@ini_set('display_errors', 'Off');
    global $api;
    global $norm;
    $norm = NotORM::getInstance();
    $api = new REST_API();
    $api->start();
}