Hi. I need your help. I have several days to try to solve a problem with my code and I do not find the error.
I leave you here what happens to me in case someone could help me.
I'm using Codeigniter 3.1.5 with HMVC and I'm using the xmlrpc libraries.
I have created two controllers xmlrpc is the part of the server
PHP Code:
<?php
class Xmlrpc extends MX_Controller {
private $username = '';
private $pass = '';
private $id_user;
public function __construct() {
parent::__construct();
$this->load->library('xmlrpc');
$this->load->library('xmlrpcs');
$config['functions']['wp.getCategories'] = array('function' => 'Xmlrpc.getCategories');
$this->xmlrpcs->initialize($config);
$this->xmlrpcs->serve();
}
public function getCategories($request){
$parameters = $request->output_parameters();
$this->load->model('publicador/Categorias_model');
$this->Publicador_categorias_model->id_user = 1;
$categorias = $this->Categorias_model->get_all();
$categories_struct = array();
foreach ($categorias as $categoria){
$struct = array(
'categoryId' => array($categoria->id,'int'),
'parentId' => array(0,'int'),
'description' => array($categoria->nombre,'string'),
'categoryDescription' => array($categoria->nombre,'string'),
'categoryName' => array($categoria->nombre,'string'),
'htmlUrl' => array('','string'),
'rssUrl' => array('','string'),
);
$categories_struct[] = array($struct,'struct');
}
$response = array($categories_struct,'array');
return $this->xmlrpc->send_response($response);
}
public function index(){
}
}
and xmlrpc_client that I use it to communicate with the server.
PHP Code:
<?php
class Xmlrpc_client extends MX_Controller {
public function __construct() {
parent::__construct();
}
public function index(){
$server_url = base_url().'/index.php/xmlrpc';
$this->load->library('xmlrpc');
$this->xmlrpc->set_debug(true);
$this->xmlrpc->server($server_url,80);
$this->xmlrpc->method('wp.getCategories');
//$this->xmlrpc->method('system.listMethods');
$params = array(
'1',
'user',
'pass',
array(
array(
'title' => array('Titulo del articulo','string'),
'description' =>array('descripcion del articulo','string'),
'categories' => array('Moda')
),'struct'
)
);
$this->xmlrpc->request($params);
if(! $this->xmlrpc->send_request()){
echo $this->xmlrpc->display_error();
}else{
echo '<pre>';
print_r($this->xmlrpc->display_response());
echo '</pre>';
}
}
}
In the creation of the server I configure the functions, but when I call them from the client it gives me this error
Quote:"Fatal error: Call to undefined method CI :: getCategories () in / home / jbom / public_html / tools / system / libraries / Xmlrpcs. Phpon line 402 "
I think the bug is trying to call CI :: getCategories () instead of Xmlrpc :: getCategories (), but I do not know why this happens.
Thanks.