I'm trying to create an API.
I have a controller that does something, and returns let's say "ABC" as a string. my url looks like this:
     http://myserver/myapp/myAPImethod/parm1
inside the method, I have code like this:
    header ('Content-Type: application/json; charset=UTF-8');
    $model= str_replace("%snv%"," ",$model);
    echo json_encode($model);
The application that consumes this API has a controller that does the following:
public function curl($url){
  //echo 'in the routine';
    $ch=curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $data=curl_exec($ch);
    print_r($data);
    curl_close($ch);
    return $data;
  }
    $url = "http://myserver/myapp/index.php/myAPImethod/hname";
    $jsondata = $this->curl($url);      
    //print_r(json_decode($jsondata));
My question is this: When I run the application that consumes my API, because I have an echo statement, it shows "ABC" on the page. But I don't want it to display the results. I just want it to pass the data to the consuming application. I've tried changing the echo statement in the API method to a "return" statement, but I don't get any data sent over to the caller.
Thanks.