elgg_view not working when in API call

I wrote a function to return my a summary of the river for a user's friends. If I put this function in just a normal view for my plugin it works perfectly, however, when this function is exposed as an API call then the part using elgg_view/elgg_extract does not work.

Here is the function in question:

function get_river_activity($username)
{
$user_guid = get_user_by_username($username)->guid;

$river_wire = elgg_get_river(
array(
'subject_guids'=>$subject_guids,
//'posted_time_lower'=>time(),
'relationship'=>'friend',
'order_by'=>'posted desc'
)
);

$result = array();
foreach($river_wire as $river_item)
{
$performed_by = get_entity($river_item->subject_guid);
$object = get_entity($river_item->object_guid);
$url = $object->getURL();
$url = stripslashes($url);

$time = time() - $object->last_action;

$points = array(
'year' => 31556926,
'month' => 2629743,
'week' => 604800,
'day' => 86400,
'hour' => 3600,
'minute' => 60,
'second' => 1
);

foreach($points as $point => $value)
{
if($elapsed = floor($time/$value) > 0)
{
$s = $elapsed>1?'s':'';
$timestamp = "$elapsed $point$s ago";
break;
}
}

$summary = elgg_extract('summary', array(), elgg_view('river/elements/summary', array('item' => $river_item)));

$string = "$summary $timestamp";

$result[$river_item->id] = $string;
}
return $result;
}

 

Here is where it is exposed to the API

expose_function("elgg.getriveractivity",
"get_river_activity",
array("username"=>array('type'=>'string')),
'Returns JSON array of all the river activity',
'GET',
false,
false
);

 

My JSON return w/o the API portion returns the summary and the timestamp but then I do it through the API it just returns the timestamp and the summary is null.