[eluser]smilie[/eluser]
Hi all,
I have a quite strange problem here and after spending quite a lot of time - I am still no closer to solution
Any help is appreciated.
Oke, to give you clear view / idea, this is the concept:
Server 1: CI application with RESTFul client;
Server 2: CI application with RestFul server.
On server 1 I have one controller which initiates RESTFul and calls 'api' on the server 2. So far, no problems.
On server 2, API receives the params (_post) and calls the model to do some DB queries. Problem occurs here. Model is loaded, but when I try to execute it - it fails.
Here is the code:
Server 1
Code:
class Login extends CPIN_Controller
{
function check_login()
{
$this->load->library('Cpin2_rest_client', array('server' => REST_SERVER));
$params = array(
'page_id' => 1,
'website_id' => 8, # 8 = MAM
'lang_id' => $this->session->userdata('lang_id')
);
$test['text'] = $this->cpin2_rest_client->post('custom_text',$params,'json');
# This code works fine and calls API script on server 2.
# More code here bellow, which is not relevant
}
}
Server 2 (API):
Code:
# Load the REST Api
require BASEPATH.'/libraries/Cpin2_rest.php';
class Mam_api extends Cpin2_rest
{
function custom_text_post()
{
# Load appropriate model
$this->load->model('api/mam','mam');
//echo '<pre>';print_r($this); echo '</pre>'; exit;
# Call the model and get data; passing vars: page_id, website_id and lang_id
$result = $this->mam->get_page_text($this->input->post('page_id'),$this->input->post('website_id'),$this->input->post('lang_id'));
if(empty($result))
{
# Could not find text in DB
$this->response('request failed',500);
}
else
{
# We got data, send it back
$this->response($result,200);
}
# Return the response
$this->response($result,200);
}
}
Problem is, on this line:
Code:
$result = $this->mam->get_page_text($this->input->post('page_id'),$this->input->post('website_id'),$this->input->post('lang_id'));
It says:
Quote:Severity: Notice
Message: Undefined property: Mam_api::$mam
Filename: api/mam_api.php
Line Number: 53
If I do:
Code:
echo '<pre>';print_r($this); echo '</pre>'; exit;
I get:
Mam_api Object
( ... * a lot of params (array values) here )
But import one is at the end, which says:
Code:
[mam] => Mam Object
(
)
(it is empty).
So - what the hell am I doing wrong here
Thanx!