public function actionCredenciales() { // 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->credencial) { case 'login': $this->_perfil = ApiHelper::obtenerPerfilUsuario($post->usuario, $post->clave); break; case 'registro': $this->_perfil = ApiHelper::crearPerfilUsuario($post->correo, $post->usuario, $post->clave, $post->ubicacion); break; default: // Model not implemented error $this->_sendResponse(501, sprintf('Error: Mode <b>list</b> is not implemented for model <b>%s</b>', $post->credencial)); Yii::app()->end(); } // Did we get some results? if (empty($this->_perfil)) { // No $this->_sendResponse(200, sprintf('No items where found for model <b>%s</b>', $post->credencial)); } else { // Send the response $this->_sendResponse(200, CJSON::encode($this->_perfil)); } }