<?php /** * Xmlrpc Class * * Created on 2011. 11. 16. * @author 불의회상 <hoksi2k@hanmail.net> * @package library * @subpackage controllers * @version 1.0 */ class Xmlrpc_lib extends CI_Controller { function __construct() { parent::__construct(); } function index() { $this->load->helper('url'); $server_url = 'http://' . $this->input->server('SERVER_NAME') . '/ci20/xmlrpcs_lib'; $this->load->library('xmlrpc'); $data = array('error' => '', 'result' => ''); $this->xmlrpc->server($server_url, 80); $this->xmlrpc->method('Greetings'); $request = array('How is it going?'); $this->xmlrpc->request($request); if (!$this->xmlrpc->send_request()) { $data['error'] = $this->xmlrpc->display_error(); } else { $data['result'] = $this->xmlrpc->display_response(); } $this->load->view('xmlrpc_lib_sample', $data); } }
<?php $this->load->view('inc/header')?> <table class="tablesorter" border="0" cellpadding="0" cellspacing="1"> <thead> <tr> <th style="text-align:center" width="20%">구분</th> <th width="80%">결과</th> </tr> </thead> <tr> <td>Result</td> <td><xmp><?php print_r($result)?></xmp></td> </tr> <tr> <td>error</td> <td><?php echo $error?></td> </tr> <tr> <td>XmlRPC SERVER</td> <td> <xmp> class Xmlrpcs_lib extends CI_Controller { function __construct() { parent::__construct(); } function index() { $this->load->library('xmlrpc'); $this->load->library('xmlrpcs'); $config['functions']['Greetings'] = array('function' => 'Xmlrpcs_lib.process'); $this->xmlrpcs->initialize($config); $this->xmlrpcs->serve(); } function process($request) { $parameters = $request->output_parameters(); $response = array( array( 'you_said' => $parameters['0'], 'i_respond' => 'Not bad at all.'), 'struct' ); return $this->xmlrpc->send_response($response); } } </xmp> </td> </tr> </table> <?php $this->load->view('inc/footer')?>
© Copyright by hoksi(Page rendered in 0.0161 seconds)