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...
Thanks for any help
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
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...
Thanks for any help
from what i've read, the restfulservice is based on simplepie.
this page should help:
you can target the xml nodes through statements like
$value->Title
$value->Link
$value->pubDate
hope it helps,
-Chris
Fatal error: Call to undefined function curl_init() in \sapphire\api\RestfulService.php on line 96
any ideas?
if you're on wamp, make sure php_curl is turned on in php.ini
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
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;
}
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.
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