コード例 #1
0
ファイル: login.php プロジェクト: ronenguttman/MusicStore
<?php

require_once dirname(__FILE__) . '/../RESTControllers/UserRESTController.php';
$user = new UserRESTController();
$app->post('/user/', function () use($user, $app) {
    $user_details = $app->request->getBody();
    $answer = $user->registerUser($user_details);
    if (!$answer["success"]) {
        $app->response()->status($answer["status"]);
        $app->response()->header('X-Status-Reason', $answer["msg"]);
    }
    echo json_encode($answer);
});
コード例 #2
0
ファイル: index.php プロジェクト: VovaMukovozov/finalProject
});
$app->get('/session', function () {
    if (isset($_SESSION['user_id'])) {
        echo $_SESSION['user_id'];
    } else {
        echo false;
    }
});
$app->get('/logout', function () {
    session_destroy();
    echo 'true';
});
// POST route
$app->post('/newUser', function () use($app, $newUser) {
    $request = $app->request->getBody();
    $user = $newUser->registerUser($request);
    echo $user;
});
$app->post('/login', function () use($app, $newUser) {
    $request = $app->request->getBody();
    $user = $newUser->loginUser($request);
    echo $user;
});
$app->post('/search', function () use($app, $search) {
    $request = $app->request->getBody();
    $album = $search->searchAlbum($request);
    echo $album;
});
$app->post('/order', function () use($app, $order) {
    $request = $app->request->getBody();
    $orders = $order->payment($request);