21493 Posts in 5784 Topics by 2622 members
General Questions
SilverStripe Forums » General Questions » Pulling RSS feeds from other sites onto my home page.
General questions about getting started with SilverStripe that don't fit in any of the categories above.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
| Go to End | Next > | |
| Author | Topic: | 3981 Views |
-
Re: Pulling RSS feeds from other sites onto my home page.

30 October 2009 at 12:28pm
i get this error when i use the simplepie class
Fatal error: Class 'SimplePie' not found in C:\wamp\www\SilverStripe01\mysite\code\HomePage.php on line 67
i am using this
function CustomRSSFeed() {
$feed = new SimplePie("http://feeds.guardian.co.uk/theguardian/world/rss");
$feed->feed->init();
$output = new DataObjectSet();
if($items = $feed->feed->get_items(0, 10)){
foreach($items as $item){
$output->push(new ArrayData(array(
"Title" => $item->get_title(),
"Link" => $item->get_link()
)));
}
}
return $output;
}and
<% control CustomRSSFeed %>
$Title
<% end_control %>
-
Re: Pulling RSS feeds from other sites onto my home page.

30 October 2009 at 1:57pm
Regarding your API key dilemma, Google allows you to simply put in localhost as your domain. This will allow you to generate and use an API key for your local WAMP or MAMP installation.
-
Re: Pulling RSS feeds from other sites onto my home page.

30 October 2009 at 2:00pm
Zim zimma - About your fatal error.... It seems you are using WAMP, so all you need to do is enable curl. click on the wamp icon, an you can enable curl in the PHP extensions. Hope this helps, dude.
-
Re: Pulling RSS feeds from other sites onto my home page.

30 October 2009 at 2:18pm
Mate...there is also a widget that pulls in news from CNN; I've not personally used it, but looks to me like it could be made to do what you need it to with a little modification to pull in just a single title from CNN, a single title from another news site, and so on...
-
Re: Pulling RSS feeds from other sites onto my home page.

31 October 2009 at 12:38am
You appear to be missing the line in your method to include SimplePie. It is not included as a default silverstripe library.
Add this:
include_once(Director::getAbsFile(SAPPHIRE_DIR . '/thirdparty/simplepie/SimplePie.php'));
To the first line of your method.
Mo
-
Re: Pulling RSS feeds from other sites onto my home page.

31 October 2009 at 4:44am
Hey Mo,
do you mean like the below... because that made the whole site not display? am I putting the
include in the right place? Thanks for help dude.function CustomRSSFeed() {
include_once(Director::getAbsFile(SAPPHIRE_DIR . '/thirdparty/simplepie/SimplePie.php'));
$feed = new SimplePie("http://feeds.guardian.co.uk/theguardian/world/rss");
$feed->feed->init();
$output = new DataObjectSet();
if($items = $feed->feed->get_items(0, 10)){
foreach($items as $item){
$output->push(new ArrayData(array(
"Title" => $item->get_title(),
"Link" => $item->get_link()
)));
}
}
return $output;
} -
Re: Pulling RSS feeds from other sites onto my home page.

31 October 2009 at 10:22am
Hmm, there are a couple of what look like errors, the biggest one is that you have used $feed->feed->methodname, it should just be $feed->methodname.
Try this:
function CustomRSSFeed() {
include_once(Director::getAbsFile(SAPPHIRE_DIR . '/thirdparty/simplepie/SimplePie.php'));
$feed = new SimplePie("http://feeds.guardian.co.uk/theguardian/world/rss", TEMP_FOLDER);
$feed->init();
$output = new DataObjectSet();
if($items = $feed->get_items(0, 10)){
foreach($items as $item){
// Cast the Title to get rid of nasty things
$title = new Text('Title');
$title->setValue($item->get_title());
$output->push(new ArrayData(array(
"Title" => $title,
"Link" => $item->get_link()
)));
}
}
return $output;
}Mo
-
Re: Pulling RSS feeds from other sites onto my home page.

1 November 2009 at 2:27am
Hey Mo,
Thanks dude! That worked. Just what I need.
How would I go about pulling feed from multiple sites. Say BBC, YAHOO, google news etc. as well as just guardian.
Really appreciate your help. I know I need to learn my php!
| 3981 Views | ||
| Go to Top | Next > |



