示例#1
0
/* Handle add friend */
$app->post('/user/{id:[0-9]+}/request', function ($request, $response, $args) {
    $token = parseToken($request);
    $friend_id = $args['id'];
    return Friends::request($response, $token, $friend_id);
});
/* Handle delete friend */
$app->delete('/user/{id:[0-9]+}/request', function ($request, $response, $args) {
    $token = parseToken($request);
    $friend_id = $args['id'];
    return Friends::unrequest($response, $token, $friend_id);
});
/* Handle get my friend requests */
$app->get('/user/me/friends/requests', function ($request, $response) {
    $token = parseToken($request);
    return Friends::requests($response, $token);
});
/* Handle get my requested friends */
$app->get('/user/me/friends/requested', function ($request, $response) {
    $token = parseToken($request);
    return Friends::requested($response, $token);
});
/* Handle get my friends */
$app->get('/user/me/friends', function ($request, $response) {
    $token = parseToken($request);
    return Friends::get($response, $token, null);
});
/* Handle get user accepted friends */
$app->get('/user/{id:[0-9]+}/friends', function ($request, $response, $args) {
    $token = parseToken($request);
    $friend_id = $args['id'];