$id = $f3->get('PARAMS.id'); // If user sending request is authenticated if ($sender_id = authenticated()) { $user = new User(null, $id); if ($user_info = $user->getInfo(false)) { $response = (object) array('status' => 1, 'status_explanation' => 'Success.', 'handle' => $user_info->handle, 'first_name' => $user_info->first_name, 'last_name' => $user_info->last_name, 'image' => $user_info->image); } else { $response = (object) array('status' => -2, 'status_explanation' => 'Couldn\'t fetch user information from database.'); } } else { $response = (object) array('status' => -1, 'status_explanation' => 'Insufficient data provided.'); } header('Content-Type: application/json'); echo json_encode($response, JSON_PRETTY_PRINT); }, $f3->get('route_ttl')); /** * Route: Retrieve all achievements * @todo the achievement system needs to be finished. Right now it just returns a list of available achievements. Nothing more. * * @example /achievements/ */ $f3->route(array('GET /achievements'), function ($f3, $params) use($db) { if ($achievements = Achievement::getAll()) { $result = (object) array('status' => 1, 'achievements' => $achievements); } else { $result = (object) array('status' => -1, 'status_explanation' => 'Could not retrieve achievements.'); } header('Content-Type: application/json'); echo json_encode($result); }, $f3->get('route_ttl')); $f3->run();