• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
1.6.2 XML-RPC Server - Load Methods from another Controller

#1
[eluser]Elliot Haughin[/eluser]
Ok, this is still an issue, and quite a big one.

I have the following basic 'Api' Controller to handle XML-RPC requests:

Code:
<?php
    
    class Api extends Controller {
    
        function Api()
        {
            parent::Controller();
            
            log_message('debug', 'Api received method');
        }
        
        function index()
        {
            $this->load->library('xmlrpc');
            $this->load->library('xmlrpcs');
            $this->load->library('server');

            $config['functions']['Posts.getLatest']     = array('function' => 'Posts.getLatest');
            $config['functions']['Posts.getSingle']     = array('function' => 'Posts.getSingle');
            
            $config['object'] = $this;
            
            $this->xmlrpcs->initialize($config);
            
            $this->xmlrpcs->serve();
        }
    }
    
?>

The server library just does some work with the params, like auth the request and remove the user/pass from the beginning of it.

Now, here's controllers/posts.php:

Code:
<?php
    
    class Posts extends Controller {

        function Posts()
        {
            parent::Controller();
            
            $this->load->library('xmlrpc');
            $this->load->library('xmlrpcs');
            $this->load->library('server');
        }
        
        function getLatest($request)
        {
            $params = $this->server->prep_request($request);
            
            if    (!empty($params[0]))
            {
                $limit = $params[0];
            }
            else
            {
                $limit = 'none';
            }
            
            $response = array('you want posts! limit '.$limit, 'string');
            
            return $this->server->send_response($response);
        }
    }

?>
Just to me on the safe side i've loaded the constructor in there too.

However, when calling Posts.getLatest from a client, I get this error:

Quote:This is not a known method for this XML-RPC Server

Try it out, it's broken! I think this is a pretty critical error, could someone confirm this ASAP?

#2
[eluser]Elliot Haughin[/eluser]
Just wanting to give this a little bump...
Mr. Jones, have you noticed this yet?

#3
[eluser]Derek Jones[/eluser]
No, I missed this thread, sorry Elliot. But we were already discussing it in this thread and in this bug report. Closing this thread for continuity; when you have a chance to try my suggestion, please reply to either the bug tracker or the existing thread and we'll go from there.

Thanks!


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.