aboutsummaryrefslogtreecommitdiff
path: root/engine/handlers/xml-rpc_handler.php
blob: ca75a9c2420804285f2b9929dd2dbc922af616f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
	/**
	 * Elgg XML-RPC handler.
	 * 
	 * @package Elgg
	 * @subpackage Core
	 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
	 * @author Curverider Ltd
	 * @copyright Curverider Ltd 2008-2009
	 * @link http://elgg.org/
	 */

	// Load Elgg engine
	define('externalpage',true);
	require_once("../start.php");
	global $CONFIG;

	// Register the error handler
	error_reporting(E_ALL); 
	set_error_handler('__php_xmlrpc_error_handler');
	
	// Register a default exception handler
	set_exception_handler('__php_xmlrpc_exception_handler'); 
	
	// Set some defaults
	$result = null;
	set_input('view', 'xml'); // Set default view regardless

	// Get the post data
	$input = get_post_data();
	
	if ($input)
	{
		// 	Parse structures from xml
		$call = new XMLRPCCall($input);
		
		// Process call
		$result = trigger_xmlrpc_handler($call);
	}
	else
		throw new CallException(elgg_echo('xmlrpc:noinputdata'));

	if (!($result instanceof XMLRPCResponse))
		throw new APIException(elgg_echo('APIException:ApiResultUnknown'));

	// Output result
	page_draw("XML-RPC", elgg_view("xml-rpc/output", array('result' => $result)));
	
?>