View Full Version : Can some one explain why this does not work?
ajfmrf
09-18-2011, 06:58 AM
<?php
require_once('simplepie.inc');
$feed = new SimplePie();
$feed = new SimplePie();
$feed->set_feed_url(array(
'http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml',
'http://rss.news.yahoo.com/rss/topstories',
'http://news.google.com/?output=atom',
'http://rss.slashdot.org/Slashdot/slashdot',
'http://rss.cnn.com/rss/cnn_topstories.rss',
'http://www.newsvine.com/_feeds/rss2/index'
));
$feed->init();
$feed->handle_content_type();
echo $feed->get_title();
?>
I get this error:
Fatal error: Call to undefined method SimplePie::set_feed_url() in /home/bud/public_html/rss/simplepie/testpage3.php on line 8
james438
09-18-2011, 08:05 AM
What is in simplepie.inc?
JShor
09-18-2011, 01:45 PM
The script is calling a function called set_feed_url() in the SimplePie class. It's as simple as that.
The script is calling a function called set_feed_url() in the SimplePie class. It's as simple as that.
and, apparently, that method does not exist. We can tell the class exists, since the error wasn't thrown on the line above. (Incidentally, why are you constructing the class twice?)
Are you sure you're calling the right method? typo/misspelled?
jscheuer1
09-18-2011, 07:37 PM
Just some more information on simplepie:
There have been many versions of simplepie.inc. The names of the functions and how to use them have at times changed.
Generally I would say make sure you're using the latest version and the correct syntax for that version. A bit tedious I know. But the code and documentation for it are on the simplepie site:
http://simplepie.org/
I've worked with it a little, it's very good for feeds.
But one could use whatever version one has and look through it to see what's in there. That can be even more tedious.
I've done it both ways, though neither for some time.
If you know which version you have, the documentation for it may still be available on the simplepie site or elsewhere around the web. It may be easier to work with. But the latest version has all the best features and security.
For an example of what an older version of simplepie can be made to do, see:
http://www.dynamicdrive.com/dynamicindex18/rssdisplaybox/index.htm
ajfmrf
09-19-2011, 02:11 AM
Thanks for taking time to look at the post.
I have found two sources of a simple php code set to use simplepie that do not work.
One is a script done twice on the simplepie website .One is barebones no styling and the second has styling.
The other script I found when surfing looking for an example that will work so that I have a basic script other the the display box script so I have more to look at and try tinkering with.
This has been a disappointing thing because I will learn more faster seeing something that works and looking at the coding used.
There has to be something siple that is out there but I have yet to find it but I will.
Bud
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.