예제 #1
0
$app->post('/comment', function () use($post, $app) {
    $details = json_decode($app->request->getBody(), true);
    echo $post->setComments($details);
});
//GET SIX RANDOM FRIENDS
$app->get('/friends/rndSix', function () use($friends) {
    $sixPack = $friends->getSixRndFriends($_SESSION["user_id"]);
    echo json_encode($sixPack);
});
//GET SIX RANDOM FRIENDS BY ID
$app->get('/friends/rndSix/:id', function ($id) use($friends) {
    $sixPack = $friends->getSixRndFriends($id);
    echo json_encode($sixPack);
});
$app->get('/friends/all', function () use($friends, $post) {
    $friend_list = $friends->getAllfriends($_SESSION['user_id']);
    foreach ($friend_list as $key => $value) {
        $friend_list[$key]['friendship_time_ago'] = $post->timeAgo($friend_list[$key]['friendship_created']);
    }
    echo json_encode($friend_list);
});
$app->get('/friends/allRequest', function () use($friends, $post) {
    $friend_list = $friends->getAllfriendsRequest($_SESSION['user_id']);
    foreach ($friend_list as $key => $value) {
        $friend_list[$key]['request_time_ago'] = $post->timeAgo($friend_list[$key]['request_created']);
    }
    echo json_encode($friend_list);
});
$app->get('/userInfo', function () use($user) {
    echo $user->getUserInfo($_SESSION['user_id']);
});