Analytics PHP API and Headers Error

I am integrating Piwik analytics api into a YII framework project and I am having a specific issue with api requests changing headers for my output. Here is the class that I started to build so you can see how I am calling the libraries. I am getting the response just fine, but it is converting my entire output from the view file to text. I can see the headers have been changed. Something about the way I am calling it is changing the headers. I can’t find information on how to turn this off or modify it with ob_flush(). Any help would be very much appreciated.

<?php class YiiPiwik { function __construct() { define('PIWIK_INCLUDE_PATH', __DIR__ .'/library'); define('PIWIK_USER_PATH', __DIR__ .'/library'); define('PIWIK_ENABLE_DISPATCH', false); define('PIWIK_ENABLE_ERROR_HANDLER', false); define('PIWIK_ENABLE_SESSION_START', false); require_once PIWIK_INCLUDE_PATH . "/index.php"; require_once PIWIK_INCLUDE_PATH . "/core/API/Request.php"; include_once PIWIK_INCLUDE_PATH.'/core/Loader.php'; spl_autoload_unregister(array('YiiBase','autoload')); spl_autoload_register(array('Piwik_Loader','autoload')); spl_autoload_register(array('YiiBase','autoload')); Piwik_FrontController::getInstance()->init(); } public function Analytics() { $request = new Piwik_API_Request('method=API.getPiwikVersion&format=php&token_auth=axxx&serialize=1 '); $requestAnswer = $request->process(); return $requestAnswer; } }