/** * Handle a web service request * * Handles requests of format: http://site/services/api/handler/response_format/request * The first element after 'services/api/' is the service handler name as * registered by {@link register_service_handler()}. * * The remaining string is then passed to the {@link service_handler()} * which explodes by /, extracts the first element as the response format * (viewtype), and then passes the remaining array to the service handler * function registered by {@link register_service_handler()}. * * If a service handler isn't found, a 404 header is sent. * * @param array $segments URL segments * @return bool */ function ws_page_handler($segments) { elgg_load_library('elgg:ws'); if (!isset($segments[0]) || $segments[0] != 'api') { return false; } array_shift($segments); $handler = array_shift($segments); $request = implode('/', $segments); service_handler($handler, $request); return true; }
<?php /** * Elgg web services handler. * * @package Elgg * @subpackage Core * @author Curverider Ltd * @link http://elgg.org/ */ // Load Elgg engine define('externalpage', true); require_once "../start.php"; // Get input $handler = get_input('handler'); $request = get_input('request'); service_handler($handler, $request);