response( array( 'error' => 'Data not found' ), 404); } /** * Method GET * Get single record (by id) * http://DOMAIN/remove/1 * @return string */ public function viewAction() { //id must be the first parameter after /remove/x return $this->response( array( 'error'=> 'Data not found' ), 404); } public function createAction() { $message = "Unexpected remove error"; $member_id = $this->requestParams["member_id"] ?? 0; try { if ($member_id==null || $member_id<1) { throw new Exception('Invalid member ID: '.$member_id); } $db = new Db(); // TODO: token check! list ($res, $err) = OAuth2::remove($db->getConnect(), $member_id); if ($res) { return $this->response($res, 200); } else if ($err && $err!="") { throw new Exception($err); } else { throw new Exception("Failed to remove user's data"); } } catch (Exception $e) { $message = $e->getMessage(); } return $this->response( array( "error" => $message ), 500); } public function updateAction() { return $this->response( array( "error" => "Update error" ), 400); } public function deleteAction() { return $this->response( array( "error" => "Delete error" ), 500); } }