00001 <?php
00002 namespace Habari;
00011 class RPCClient
00012 {
00013 private $url;
00014 private $method;
00015 private $params;
00016 private $request_body;
00017 private $result = false;
00018
00024 function __construct( $url, $method, $params )
00025 {
00026 if ( ! function_exists( 'xmlrpc_encode_request' ) ) {
00027 return Error::raise( _t( 'xmlrpc extension not found' ) );
00028 }
00029 $this->url = $url;
00030 $this->method = $method;
00031 $this->params = $params;
00032
00033 $this->request_body = xmlrpc_encode_request( $method, $params );
00034 }
00035
00039 public function execute()
00040 {
00041 $rr = new RemoteRequest( $this->url, 'POST' );
00042 $rr->add_header( 'Content-Type: text/xml;charset=utf-8' );
00043 $rr->set_body( $this->request_body );
00044
00045
00046 $rr->execute();
00047
00048
00049 $this->result = xmlrpc_decode( $rr->get_response_body() );
00050 }
00051
00055 public function get_result()
00056 {
00057 return $this->result;
00058 }
00059 }
00060
00061 ?>