$app->response->status(404); echo json_encode(["status" => "User not found"]); } }); $app->get('/users/:hash_id/posts', function ($hash_id) use($app) { $req = $app->request; $prms = []; if ($req->get("limit")) { $prms['limit'] = $req->get("limit"); } if ($req->get("offset") && $req->get("direction")) { $prms['offset'] = $req->get("offset"); $prms['direction'] = $req->get("direction"); } try { $id = User::decodeHashID($hash_id); } catch (Exception $e) { $id = $hash_id; } $prms['user_id'] = $id; $posts = App::getActivities($prms); echo json_encode(Utility::formatActivitiesToPosts($posts, $app)); }); $app->post('/users/:id/posts', function ($id) use($app) { $o = $app->request->getBody(); $o = json_decode($o); $u = new User($app->environment()['testify.user_id']); if ($u->getID() != $id) { $app->response->status(403); echo json_encode(["status" => false, "description" => "Wrong account"]); return;