Utils::echoResponse($response); }); //RESTful for SharcExperience $app->post('/experiences', function () use($app) { //Check authentication $rs = UserService::checkAuthentication($app->request->headers->get('apiKey')); if ($rs["status"] != SUCCESS) { Utils::echoResponse($rs); return; } //Get a user sent from client and convert it to a json object $jsonExperience = $app->request->getBody(); $objExperience = json_decode($jsonExperience, true); $objExperience['designerId'] = $rs['data']->id; //So even with a valid apiKey, the designer can access her own resources only $response = ExperienceService::addNewExperience($objExperience); Utils::echoResponse($response); }); $app->put('/experiences/:id', function ($id) use($app) { //Check authentication $rs = UserService::checkAuthentication($app->request->headers->get('apiKey')); if ($rs["status"] != SUCCESS) { Utils::echoResponse($rs); return; } $jsonExperience = $app->request->getBody(); $objExperience = json_decode($jsonExperience, true); $response = ExperienceService::updateExperience($id, $objExperience, $rs['data']->id); Utils::echoResponse($response); }); $app->post('/publishExperience/:id', function ($id) use($app) {