aboutsummaryrefslogtreecommitdiff
path: root/engine/classes/XMLRPCCall.php
blob: 047f36d7bed03582aa3f332e140a339587ae3550 (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
50
51
52
53
54
55
56
57
58
59
<?php
/**
 * @class XMLRPCCall
 * This class represents 
 */
class XMLRPCCall
{
	/** Method name */
	private $methodname;
	/** Parameters */
	private $params;
	
	/**
	 * Construct a new XML RPC Call
	 *
	 * @param string $xml
	 */
	function __construct($xml)
	{
		$this->parse($xml);
	}
	
	/**
	 * Return the method name associated with the call.
	 *
	 * @return string
	 */
	public function getMethodName() { return $this->methodname; }
	
	/**
	 * Return the parameters.
	 * Returns a nested array of XmlElement.
	 * 
	 * @see XmlElement 
	 * @return array
	 */
	public function getParameters() { return $this->params; }
	
	/**
	 * Parse the xml into its components according to spec. 
	 * This first version is a little primitive. 
	 *
	 * @param string $xml
	 */
	private function parse($xml)
	{
		$xml = xml_to_object($xml);
		
		// sanity check
		if ((isset($xml->name)) && (strcasecmp($xml->name, "methodCall")!=0))
			throw new CallException(elgg_echo('CallException:NotRPCCall'));
		
		// method name
		$this->methodname = $xml->children[0]->content;
		
		// parameters 
		$this->params = $xml->children[1]->children;			
	}
}