From 79e77bd72aeb27c82ff4ef0b905d2a75f00f8258 Mon Sep 17 00:00:00 2001 From: icewing Date: Fri, 16 May 2008 11:43:57 +0000 Subject: Marcus Povey * Refactored API under services git-svn-id: https://code.elgg.org/elgg/trunk@649 36083f99-b078-4883-b0ff-0f9b5a30f544 --- endpoints/rest.php | 59 --------------------------------------------------- mod/apitest/start.php | 2 +- services/api/rest.php | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 60 deletions(-) delete mode 100644 endpoints/rest.php create mode 100644 services/api/rest.php diff --git a/endpoints/rest.php b/endpoints/rest.php deleted file mode 100644 index 2944a24ff..000000000 --- a/endpoints/rest.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Curverider Ltd 2008 - * @link http://elgg.org/ - */ - - /** - * Start the Elgg engine - */ - require_once('../engine/start.php'); - global $CONFIG; - - // Register the error handler - error_reporting(E_ALL); - set_error_handler('__php_api_error_handler'); - - // Register a default exception handler - set_exception_handler('__php_api_exception_handler'); - - // Check to see if the api is available - if ((isset($CONFIG->disable_api)) && ($CONFIG->disable_api == true)) - throw new ConfigurationException("Sorry, API access has been disabled by the administrator."); - - // Register some default PAM methods, plugins can add their own - register_pam_handler('pam_auth_session'); - register_pam_handler('pam_auth_hmac'); - - // Get parameter variables - $method = get_input('method'); - $result = null; - - // Authenticate session - if (pam_authenticate()) - { - // Authenticated somehow, now execute. - $token = ""; - $params = $_REQUEST; - if (isset($params['auth_token'])) $token = $params['auth_token']; - - $result = execute_method($method, $params, $token); - } - else - throw new SecurityException("No authentication methods were found that could authenticate this API request."); - - // Finally output - if (!($result instanceof GenericResult)) - throw new APIException("API Result is of an unknown type, this should never happen."); - - // Output the result - page_draw($method, elgg_view("api/output", array("result" => $result))); - -?> \ No newline at end of file diff --git a/mod/apitest/start.php b/mod/apitest/start.php index ded4d5d0d..947da115c 100644 --- a/mod/apitest/start.php +++ b/mod/apitest/start.php @@ -163,7 +163,7 @@ $endpoint = sanitise_string($endpoint); if ($endpoint=="") - $endpoint = $CONFIG->wwwroot . "endpoints/rest.php"; + $endpoint = $CONFIG->wwwroot . "services/api/rest.php"; $API_CLIENT->api_key = $apikey; $API_CLIENT->secret = $secret; diff --git a/services/api/rest.php b/services/api/rest.php new file mode 100644 index 000000000..2944a24ff --- /dev/null +++ b/services/api/rest.php @@ -0,0 +1,59 @@ + + * @copyright Curverider Ltd 2008 + * @link http://elgg.org/ + */ + + /** + * Start the Elgg engine + */ + require_once('../engine/start.php'); + global $CONFIG; + + // Register the error handler + error_reporting(E_ALL); + set_error_handler('__php_api_error_handler'); + + // Register a default exception handler + set_exception_handler('__php_api_exception_handler'); + + // Check to see if the api is available + if ((isset($CONFIG->disable_api)) && ($CONFIG->disable_api == true)) + throw new ConfigurationException("Sorry, API access has been disabled by the administrator."); + + // Register some default PAM methods, plugins can add their own + register_pam_handler('pam_auth_session'); + register_pam_handler('pam_auth_hmac'); + + // Get parameter variables + $method = get_input('method'); + $result = null; + + // Authenticate session + if (pam_authenticate()) + { + // Authenticated somehow, now execute. + $token = ""; + $params = $_REQUEST; + if (isset($params['auth_token'])) $token = $params['auth_token']; + + $result = execute_method($method, $params, $token); + } + else + throw new SecurityException("No authentication methods were found that could authenticate this API request."); + + // Finally output + if (!($result instanceof GenericResult)) + throw new APIException("API Result is of an unknown type, this should never happen."); + + // Output the result + page_draw($method, elgg_view("api/output", array("result" => $result))); + +?> \ No newline at end of file -- cgit v1.2.3