Welcome Guest, Not a member yet? Register   Sign In
XML-RPC from Non-Codeigniter source
#6

[eluser]gtech[/eluser]
Hi i gave your code a go, and found a solution.. you were very close.

here is what I did, note the php_xmlrpc_encode was the problem as you thought.. the parameters I passed also gets passed in as an array, so I simply return $pars[0].

hope this helps.

Code:
<?php
    include('lib/xmlrpc.inc');
    include('lib/xmlrpcs.inc');
    $c = new xmlrpc_client('/CI1.6.1/index.php/cif_s', 'localhost', 80); // Set up client

    // I managed to use this way of passing the params.
    $msg = new xmlrpcmsg('Add_contact', array(new xmlrpcval('param1','string'),new xmlrpcval(2,'int')));

    $r = $c->send($msg);
    echo '<pre>';
    print_r( $r );
    echo '</pre>';
?&gt;
Code:
&lt;?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Cif_s extends Controller {

    function Cif_s() {
        parent::Controller();
    }
    /*--------------------------------*/    
    function index() {
        $this->load->library('xmlrpc');
        $this->load->library('xmlrpcs');
        $config['functions']['Add_contact'] = array('function' => 'Cif_s.add_contact');
        $this->xmlrpcs->initialize($config);
        $this->xmlrpcs->serve();
    }
    /*--------------------------------*/
    function add_contact($request) {        
        $pars = $request->output_parameters();
        // I return $pars[0] I could also return $pars[1]
        $response = array(
                        array('pars' => array($pars[0], 'string')
                    ),'struct');                    
        return $this->xmlrpc->send_response($response);
    }
}
?&gt;


RESPONSE:
Code:
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
<methodResponse>
<params>
<param>
<value>
<struct>
<member>
<name>pars</name>
<value>
<string>param1</string>
.....
//woo hoo it worked


Messages In This Thread
XML-RPC from Non-Codeigniter source - by El Forum - 05-15-2008, 03:20 PM
XML-RPC from Non-Codeigniter source - by El Forum - 05-15-2008, 05:22 PM
XML-RPC from Non-Codeigniter source - by El Forum - 05-15-2008, 09:30 PM
XML-RPC from Non-Codeigniter source - by El Forum - 05-16-2008, 04:54 AM
XML-RPC from Non-Codeigniter source - by El Forum - 05-16-2008, 08:10 AM
XML-RPC from Non-Codeigniter source - by El Forum - 05-16-2008, 10:28 AM
XML-RPC from Non-Codeigniter source - by El Forum - 09-29-2008, 09:15 PM



Theme © iAndrew 2016 - Forum software by © MyBB