diff options
author | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-02-21 17:30:29 +0000 |
---|---|---|
committer | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-02-21 17:30:29 +0000 |
commit | 5e28de6ea706ad1bd89b744311e1291f8354f73e (patch) | |
tree | 3e86ebefbdc2a6c1d441b6000980b97a11335d76 /services/api/rest_api.php | |
parent | d8af70961afb5cfab76ffffa3672ed6f1040baf4 (diff) | |
download | elgg-5e28de6ea706ad1bd89b744311e1291f8354f73e.tar.gz elgg-5e28de6ea706ad1bd89b744311e1291f8354f73e.tar.bz2 |
Apache's MultiViews was matching the rest page handler incorrectly
git-svn-id: http://code.elgg.org/elgg/trunk@3958 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'services/api/rest_api.php')
-rw-r--r-- | services/api/rest_api.php | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/services/api/rest_api.php b/services/api/rest_api.php new file mode 100644 index 000000000..4d3e39aaa --- /dev/null +++ b/services/api/rest_api.php @@ -0,0 +1,58 @@ +<?php +/** + * Rest endpoint. + * The API REST endpoint. + * + * @package Elgg + * @subpackage API + * @author Curverider Ltd <info@elgg.com> + * @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 SecurityException(elgg_echo('SecurityException:APIAccessDenied')); +} + +// plugins should return true to control what API and user authentication handlers are registered +if (trigger_plugin_hook('rest', 'init', null, false) == false) { + // check session - this usually means a REST call from a web browser + register_pam_handler('pam_auth_session'); + // user token can also be used for user authentication + register_pam_handler('pam_auth_usertoken'); + + // simple API key check + register_pam_handler('api_auth_key', "sufficient", "api"); + // hmac + register_pam_handler('api_auth_hmac', "sufficient", "api"); +} + +// Get parameter variables +$method = get_input('method'); +$result = null; + +// this will throw an exception if authentication fails +authenticate_method($method); + +$result = execute_method($method); + + +if (!($result instanceof GenericResult)) { + throw new APIException(elgg_echo('APIException:ApiResultUnknown')); +} + +// Output the result +page_draw($method, elgg_view("api/output", array("result" => $result)));
\ No newline at end of file |