Jump to:

17452 Posts in 4473 Topics by 1971 members


SilverStripe Forums » Archive » restful service rss

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Page: 1
Go to End
Author Topic: 3719 Views
  • superautomatic
    Community Member
    53 Posts

    restful service rss Link to this post

    Hi, I'm trying to import and display an external rss-feed, as in the example code on "How to use RestfulService to easily embed an RSS feed" (http://doc.silverstripe.com/doku.php?id=restfulservice)

    It works well if I use the rss feed in the example, but if I use another rss (for example http://www.euro2008.uefa.com/rss/index.xml), it returns nothing at all. Why is this?

  • Willr
    Forum Moderator
    5511 Posts

    Re: restful service rss Link to this post

    The blog modules RSS Feed widget uses SimplePie. I dont know how it differs from RestFulService it terms of what you actually want to do but that uses something like


  • Reflektera
    49 Posts

    Re: restful service rss Link to this post

    I have the same problem as superautomatic. Got it working as described in the documentation, with help from the comments. But it only works with that feed, none else.

    I can't seem to get the http://mypage/PageComment/rss/ feed working either. It says that Xml- or textdeclaration not in beginning of entity. Any clues on that?

    Besides that there is a typo in RestfulService.php, in line 134. $respnoseBody should be $responseBody I suppose.

  • jam13
    121 Posts

    Re: restful service rss Link to this post

    With 2.3 coming up I decided to use the RestfulService.php from the 2.3 branch instead of the current stable one, and as it is pretty self contained it seems to work fine on 2.2.3.

    The problem I had was with the difference in format between RSS feeds of different versions: RSS 1.0 places the <item> tags outside the <channel>, while RSS 2.0 places them outside. The end result of this is that you need to call getValues slightly differently, here's a snippet of code that I wrote for a recent site:

    function Items($limit = 3) {
    if(!$this->Link) return 0;
    $feed = new RestfulService($this->Link);
    $feedXML = $feed->request()->getBody();

    // Extract items from feed
    if($this->Type == 'RSS2') {
    $result = $feed->getValues($feedXML, 'channel', 'item');
    } elseif($this->Type == 'RSS1') {
    $result = $feed->getValues($feedXML, 'item');

    // Return items up to limit
    return $result->getRange(0,$limit);

    Hope that helps.

    BTW I've posted a patch to Trac that re-enables the response caching as I couldn't live without it for this site. Not sure whether it's good enough for inclusion in trunk though.

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.