commit 9e0b7eb5a167f928b46d7b06a92978817c578df9 Author: Pierre Date: Wed May 17 13:48:24 2017 +0200 Initial commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..085d182 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# The Comunic API + +This project is the main Comunic RestAPI. It assures data backend support \ No newline at end of file diff --git a/RestControllers/.htaccess b/RestControllers/.htaccess new file mode 100644 index 0000000..14249c5 --- /dev/null +++ b/RestControllers/.htaccess @@ -0,0 +1 @@ +Deny from all \ No newline at end of file diff --git a/RestControllers/changesController.php b/RestControllers/changesController.php new file mode 100644 index 0000000..444777d --- /dev/null +++ b/RestControllers/changesController.php @@ -0,0 +1,28 @@ + $to*1) + Rest_fatal_error(401, "Please specify a valid interval !"); + + + //We try to get changes of the specified period + $changes = DW::get()->changes->get($from*1, $to*1); + if($changes === false) + Rest_fatal_error(500, "Couldn't get changes of the specified period !"); + + //Return the informations + return $changes; + } +} \ No newline at end of file diff --git a/RestControllers/listsController.php b/RestControllers/listsController.php new file mode 100644 index 0000000..fb30a88 --- /dev/null +++ b/RestControllers/listsController.php @@ -0,0 +1,82 @@ +lists->getCurrent()) + Rest_fatal_error(500, "Couldn't get current list !"); + } + else { + //Get the list of the specified timestamp + if(!$list = DW::get()->lists->getOnTimestamp($time*1)) + Rest_fatal_error(500, "Couldn't get the list on specified timestamp !"); + } + + //Return the list + return $list; + } + + + /** + * Update the current list + * + * @url POST /list/update + */ + public function updateList(){ + + //Authentication required (protected method) + if(!DW::get()->auth->restAuth()) + Rest_fatal_error(401, "Authentication required !"); + + //Try to update list + if(!DW::get()->lists->update()) + Rest_fatal_error(500, "Couldn't update Decodex list !"); + + //Else it is a success + return array("success" => "This list was successfully updated !"); + } + + /** + * Get the list of available websites using urls + * + * @url GET /list/urls + */ + public function getListSites(){ + //We try to get the list of urls + if(!$list = DW::get()->lists->getListUrls()) + Rest_fatal_error(500, "Couldn't get the list of urls !"); + + //Return the list + return $list; + } + + /** + * Get the list of URLs only + * + * @url GET /list/urls/only + */ + public function getURLsOnly(){ + //We try to get the list of urls + if(!$list = DW::get()->lists->getListUrls(true)) + Rest_fatal_error(500, "Couldn't get the list of urls !"); + + //Return the list + return $list; + } +} \ No newline at end of file diff --git a/RestControllers/sitesController.php b/RestControllers/sitesController.php new file mode 100644 index 0000000..d6dbfa1 --- /dev/null +++ b/RestControllers/sitesController.php @@ -0,0 +1,56 @@ +sites->getInfosFromURL($url)) + Rest_fatal_error(500, "Couldn't get informations about the URL !"); + + //Return the informations + return $infos; + } + + /** + * Get the informations history about a website given a URL + * + * @url GET /site/$url/history + * @url POST /site/history + */ + public function getInfosURLHistory($url=false){ + + //We check if the URL was passed in $_POST mode + if(!$url){ + if(!isset($_POST['url'])) + Rest_fatal_error(401, "Please specify an URL !"); + + $url = $_POST['url']; + } + + //We try to get informations about a websites using its URL + if(!$infos = DW::get()->sites->getInfosFromURL($url, 0)) + Rest_fatal_error(500, "Couldn't get history informations about the URL !"); + + //Return the informations + return $infos; + } +} \ No newline at end of file diff --git a/RestControllers/welcomeController.php b/RestControllers/welcomeController.php new file mode 100644 index 0000000..a3f87d6 --- /dev/null +++ b/RestControllers/welcomeController.php @@ -0,0 +1,25 @@ + "This service watches DecodexList evolutions, stores them and let its client access them.", + "githubURL" => "https://github.com/pierre42100/decodexwatcherapi/", + "clientURL" => "https://decodexwatcher.communiquons.org/", + "apiSchema" => "https://swagger.decodexwatcher.communiquons.org/" + ); + } + +} \ No newline at end of file diff --git a/index.php b/index.php new file mode 100644 index 0000000..06f6608 --- /dev/null +++ b/index.php @@ -0,0 +1,14 @@ +