Jump to:

23490 Posts in 18996 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » SimplePie Thumbnail From RSS?

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 2790 Views
  • 3 midgets In a man suit
    Avatar
    Community Member
    13 Posts

    SimplePie Thumbnail From RSS? Link to this post

    Hi how can I pull thumbnails from an RSS Feed with the simple pie plugin?

    everything else works great I looked on the simplepie documentation on it's website.
    here is what I tried but it failed...

    http://pastie.org/696188

    Thanks for any help

  • ChrisBryer
    Avatar
    Community Member
    95 Posts

    Re: SimplePie Thumbnail From RSS? Link to this post

    from what i've read, the restfulservice is based on simplepie.
    this page should help:

    http://doc.silverstripe.org/doku.php?id=restfulservice#how_to_use_restfulservice_to_easily_embed_an_rss_feed

    you can target the xml nodes through statements like
    $value->Title
    $value->Link
    $value->pubDate

    hope it helps,
    -Chris

  • 3 midgets In a man suit
    Avatar
    Community Member
    13 Posts

    Re: SimplePie Thumbnail From RSS? Link to this post

    Fatal error: Call to undefined function curl_init() in \sapphire\api\RestfulService.php on line 96

    any ideas?

  • ChrisBryer
    Avatar
    Community Member
    95 Posts

    Re: SimplePie Thumbnail From RSS? Link to this post

    if you're on wamp, make sure php_curl is turned on in php.ini

  • 3 midgets In a man suit
    Avatar
    Community Member
    13 Posts

    Re: SimplePie Thumbnail From RSS? Link to this post

    Well that was the issue, but now a new issue. the example give works great with the feed from delicous if I return any other rss feed url I get nada. no errors just no results

  • 3 midgets In a man suit
    Avatar
    Community Member
    13 Posts

    Re: SimplePie Thumbnail From RSS? Link to this post

    ok I almost have it working but, the item is called <photo:thumbnail>

    how do I call it? also for somereason it won't let me strip the tags from the description

    function RestfulLinks(){
    $output = new DataObjectSet();
    $feed = new RestfulService("http://feeds.nbcdfw.com/nbcdfw/news/sports");
    $feedXML = $feed->request()->getBody();
    $result = $feed->getValues($feedXML, 'channel', 'item');
    foreach ($result as $key => $value) {

             $title = new Text('Title');
             $title->setValue($value->title);
             
             $desc = new HTMLText('Description');
    $desc->setValue(strip_tags($value->description));
                      
          $output->push(new ArrayData(array(
    'Title' => $title,
    'Description' => $desc,
    )));
    }

           return $output;
          
    }   

  • dalesaurus
    Avatar
    Community Member
    283 Posts

    Re: SimplePie Thumbnail From RSS? Link to this post

    Right, you're going to have to customize your parsing rules for whatever feed you're ingesting.

    Have you tried casting the data into a string first? ie.

    $desc = strip_tags((string)$value->description);

    Also, you shouldn't have to create a new Text() and HTMLText() for each item before putting it in the DataObjectSet. You can just leave it as a plain old string.

  • ChrisBryer
    Avatar
    Community Member
    95 Posts

    Re: SimplePie Thumbnail From RSS? Link to this post

    as far as the <photo:thumbnail> node is concerned, i've never tried parsing a namespaced node, but here are some thoughts..
    $result is an array, so you may be able to use $value['photo:thumbnail'].

    you could also try entering Debug::dump($value) to print out all the child nodes of $value.

    hope it helps,
    -Chris

    2790 Views
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.