I've set up a RestfulService function to output an RSS feed, which works fine.
It's pretty much as described in the documentation here:
http://doc.silverstripe.org/doku.php?id=restfulservice
I've tried to modify the code myself to limit the number of results displayed to 5 instead of the 20 or so which are in the incoming feed.
My code looks like this currently:
// Accepts an RSS feed URL and outputs a list of links from it
function RestfulLinks($url){
$feed = new RestfulService($url);
$feedXML = $feed->request()->getBody();
$result = $feed->getValues($feedXML, 'channel', 'item');
$output = '';
foreach ($result as $key => $value) {
// Fix quote encoding
$description = str_replace('"', '"', $value->description);
$output .= '<li><a href="'.$value->link.'">'.$value->title.'</a><br />'.$description.'</li>';
}
return $output ->getRange(0,5);
}
I get the error:
Fatal error: Call to a member function getRange() on a non-object in /mysite/code/Page.php on line 87
(line 87 is the "return $output ->getRange(0,5);")
Can anyone suggest which direction I should be going?
Thanks!