public function actionArticulo() { // Parse the PUT parameters. This didn't work: parse_str(file_get_contents('php://input'), $put_vars); $json = file_get_contents('php://input'); //$GLOBALS['HTTP_RAW_POST_DATA'] is not preferred: http://www.php.net/manual/en/ini.core.php#ini.always-populate-raw-post-data $post = CJSON::decode($json, false); //true means use associative array switch ($post->operacion) { case 'listado': $this->_articulo = ApiHelper::listadoArticulo(); break; case 'listadocategoria': $this->_articulo = ApiHelper::listadoCategoriaArticulo($post); break; case 'busqueda': $this->_articulo = ApiHelper::busquedaArticulo($post->filtro); break; case 'detalle': $this->_articulo = ApiHelper::detalleArticulo($post); break; case 'megusta': $this->_articulo = ApiHelper::megustaArticulo($post); break; case 'crear': $this->_articulo = ApiHelper::crearArticulo($post); break; default: // Model not implemented error $this->_sendResponse(501, sprintf('Error: Mode <b>list</b> is not implemented for model <b>%s</b>', $post->operacion)); Yii::app()->end(); } // Did we get some results? if (empty($this->_articulo)) { // No $this->_sendResponse(200, sprintf('No items where found for model <b>%s</b>', $post->operacion)); } else { // Send the response $this->_sendResponse(200, CJSON::encode($this->_articulo)); } }