0

I try the rest api. When I use GET method, the code run. But when I use POST method the code return false.

Here is my restclient controller:

$this->load->spark('restclient/2.1.0');

$this->load->library('rest');

$this->rest->initialize(array('server' => 'serverhere'));


$name=$this->input->post('name');
$params = array('name' => $name);
$uri = 'userscontroller/user';

$result = $this->rest->post($uri, $params,"json");
$this->rest->debug();

Here is my restserver controller:

public function name_get(){

$name=$this->get("name");

$this->response($name);

}

public function name_post(){

$name=array('name'=>$this->input->post("name"));
$this->response($name);

}

The name_post response is always FALSE. Help!

Ijas Ameenudeen
  • 9,069
  • 3
  • 41
  • 54
user3172495
  • 13
  • 1
  • 7
  • in my opinion is return false because it is default behavior of function. you not returning anything (zero, null, nada, 0) then you have got false. Modify your function to if statement and put something like this: if ( something ) { return true; } else {return false }, look this: http://stackoverflow.com/questions/1218580/what-does-a-php-function-return-by-default – przeqpiciel Mar 20 '14 at 05:13
  • $this->response($name); this one return the value..when I use get method the function return the value of $name...but when I use the post method..the function return false – user3172495 Mar 20 '14 at 05:19
  • because when you are use post method you call php interpreter and code above is running on server side and put empty HTML and this is why you have false ( null contenet = false ) in test put to your function [code] echo 'hello world'; [/code] and wrote is it something change – przeqpiciel Mar 20 '14 at 05:22

0 Answers0