Example #1
0
    echo json_encode($post->publishComment($_SESSION['auth']['user_id'], $data->post_id, $data->content));
});
/**
 * Friends
 */
$app->post('/friend', function () use($friend, $app) {
    $data = json_decode($app->request->getBody());
    echo json_encode($friend->addFriend($_SESSION['auth']['user_id'], $data->friend_id));
});
$app->delete('/friend', function () use($friend, $app) {
    $data = json_decode($app->request->getBody());
    echo json_encode($friend->deleteFriend($_SESSION['auth']['user_id'], $data->friend_id));
});
$app->delete('/friends', function () use($friend, $app) {
    $data = json_decode($app->request->getBody());
    echo json_encode($friend->deleteFriends($_SESSION['auth']['user_id'], $data->friends_to_remove));
});
/**
 * Notifications
 */
$app->get('/notifications/:type/:offset/:limit', function ($type, $offset, $limit) use($friend) {
    echo json_encode($friend->getNotifications($type, $offset, $limit));
});
/**
 * Login
 */
$app->post('/login', function () use($app, $login, $user) {
    $body = json_decode($app->request->getBody());
    $email = $body[0]->value;
    $password = $body[1]->value;
    $status = $login->login($email, $password, $user);