| // +----------------------------------------------------------------------+ // // @(#) $Id: class.Eventum_RPC.php,v 1.1 2008/12/02 17:51:03 glen Exp $ require_once 'XML/RPC.php'; class Eventum_RPC_Exception extends Exception { }; class Eventum_RPC { private $user; private $password; private $url; public function setAuth($user, $password) { $this->user = $user; $this->password = $password; } public function setURL($url) { $this->url = $url; } private $client; private $debug = 0; private function getClient() { if (isset($this->client)) { return $this->client; } $data = parse_url($this->url); if (!isset($data['port'])) { $data['port'] = $data['scheme'] == 'https' ? 443 : 80; } $data['path'] .= 'rpc/xmlrpc.php'; $this->client = new XML_RPC_Client($data['path'], $data['host'], $data['port']); $this->client->setDebug($this->debug); return $this->client; } public function setDebug($debug) { $this->debug = $debug; } public function __call($method, $args) { $params = array(); $params[] = new XML_RPC_Value($this->user, 'string'); $params[] = new XML_RPC_Value($this->password, 'string'); foreach ($args as $arg) { $type = gettype($arg); if ($type == 'integer') { $type = 'int'; } $params[] = new XML_RPC_Value($arg, $type); } $msg = new XML_RPC_Message($method, $params); $client = $this->getClient(); $result = $client->send($msg); if ($result->faultCode()) { throw new Eventum_RPC_Exception($result->faultString()); } $details = XML_RPC_decode($result->value()); foreach ($details as $k => $v) { $details[$k] = base64_decode($v); } return $details; } }; /* $eventum_url = 'https://eventum.example.org/'; $user_email = 'xxx'; $user_password = 'xxx'; $client = new Eventum_RPC(); $client->setAuth($user_email, $user_password); $client->setURL($eventum_url); #$client->setDebug(1); $issue_id = $argc > 1 ? (integer )$argv[1] : 0; if ($issue_id > 0) { $details = $client->getIssueDetails((int )$issue_id); echo $details['iss_summary'], "\n"; } */