Debt Consolidation - Wordpress magazine themes - Debt Consolidation - Find jobs - Credit Card

PDA

View Full Version : Using an RSS Feed (This is Easy)


Pages : [1] 2

yfs1
Jan 5th 2005, 4:23 am
Hello all, I wanted to be sure I always had fresh content on some of my sites so I started looking into RSS feeds but it was always way more complicated than it should have been.

Well after a few weeks of experimentation, I have the code for two scenarios:

1.) Add a straight RSS feed
2.) Add a rotating RSS feed

Just change the feed (it should be obvious where that is :) )

You can get just about any feed you can think about here: www.syndic8.com

For a Straight Feed

<?php
$insideitem = false;
$tag = "";
$title = "";
$description = "";
$link = "";
function startElement($parser, $name, $attrs) {
global $insideitem, $tag, $title, $description, $link;
if ($insideitem) {
$tag = $name;
} elseif ($name == "ITEM") {
$insideitem = true;
}
}
function endElement($parser, $name) {
global $insideitem, $tag, $title, $description, $link;
if ($name == "ITEM") {
printf("<dt><b><a href='%s'>%s</a></b></dt>",
trim($link),htmlspecialchars(trim($title)));
printf("<dt>%s</dt><br><br>",htmlspecialchars(trim($description)));
$title = "";
$description = "";
$link = "";
$insideitem = false;
}
}
function characterData($parser, $data) {
global $insideitem, $tag, $title, $description, $link;
if ($insideitem) {
switch ($tag) {
case "TITLE":
$title .= $data;
break;
case "DESCRIPTION":
$description .= $data;
break;
case "LINK":
$link .= $data;
break;
}
}
}
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
$fp = fopen("http://michaelthompson.org/news/goo-world.xml","r")
or die("Error reading RSS data.");
while ($data = fread($fp, 4096))
xml_parse($xml_parser, $data, feof($fp))
or die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
fclose($fp);
xml_parser_free($xml_parser);
?>

For a rotating feed:

<?php
$insideitem = false;
$tag = "";
$title = "";
$description = "";
$link = "";
$locations = array('http://michaelthompson.org/news/goo-world.xml', 'http://forums.seochat.com/external.php', 'http://michaelthompson.org/news/goo-world.xml');
srand((float) microtime() * 10000000); // seed the random gen
$random_key = array_rand($locations);
function startElement($parser, $name, $attrs) {
global $insideitem, $tag, $title, $description, $link;
if ($insideitem) {
$tag = $name;
} elseif ($name == "ITEM") {
$insideitem = true;
}
}
function endElement($parser, $name) {
global $insideitem, $tag, $title, $description, $link;
if ($name == "ITEM") {
printf("<dt><b><a href='%s' target=new>%s</a></b></dt>",
trim($link),htmlspecialchars(trim($title)));
printf("<dt>%s</dt><br><br>",htmlspecialchars(trim($description)));
$title = "";
$description = "";
$link = "";
$insideitem = false;
}
}
function characterData($parser, $data) {
global $insideitem, $tag, $title, $description, $link;
if ($insideitem) {
switch ($tag) {
case "TITLE":
$title .= $data;
break;
case "DESCRIPTION":
$description .= $data;
break;
case "LINK":
$link .= $data;
break;
}
}
}
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
$fp = fopen($locations[$random_key], 'r')
or die("Error reading RSS data.");
while ($data = fread($fp, 4096))
xml_parse($xml_parser, $data, feof($fp))
or die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
fclose($fp);
xml_parser_free($xml_parser);
?>

DangerMouse
Jan 5th 2005, 4:39 am
Cool, thanks for that... Does it work on all RSS versions?

yfs1
Jan 5th 2005, 5:09 am
I haven't had a feed I couldn't use yet. If you want to post some feeds I will try them for you (I am a trial and error kind of person).

You can check out the rotating feed on my directory:
www.kwikgoblin.com

It is around 2-3 weeks old and got a PR3.

I believe however the rotating content has helped by encouraging Google to keep indexing. Google added 22 pages from day 7 to 14. Hopefully that keeps growing exponentially.

I'm still experimenting with the feed code on that site (the format), so if it is down for 2-3 minutes it is because I am working on it.

TwisterMc
Jan 5th 2005, 6:11 am
I just added my blog RSS feed to my homepage using Magpie RSS. Still needs some tweaks if I want descriptions but I have the titles and links at least. :)

ResaleBroker
Jan 5th 2005, 9:41 am
That's great. Thanks!

Thewormman
Jan 5th 2005, 1:41 pm
Tried it works great!

Thanks for sharing

crafty
Jan 5th 2005, 3:47 pm
Thanks for the informative post YSFI
I am obviously doing something wrong as I tried both the scripts on a page of mine as a test without altering anything and they would not work.
(Probably just a simple thing that I have missed)
Any advice that you could offer would be most appreciated.
Tony

yfs1
Jan 6th 2005, 1:28 am
First of all, what kind of page is it?

If it is an html page, then be sure PHP is enabled.

Put a piece of test PHP on your page and see if that works.

I am answering this way because you called it a script which makes me think you are adding it into an html page although I could easily be wrong.

Cheers

DangerMouse
Jan 6th 2005, 1:57 am
It could also be that you hosting provider (like mine :mad: ) is blocking outgoing port 80 connections on your web server... I had to ask them to open digitalpoint.com up on their fire wall before I got the co-op stuff running!

crafty
Jan 6th 2005, 3:51 am
Thanks..
Yes I am attempting to add it to an html page.
Hosting set up describes php as
"PHP version 4.3.9"
and I use php to redirect to affiliate URLs.
if you can not think of a solution I will contact host as Dangermouse suggests.
cheers
Tony

ZeRo_CoOl
Jan 6th 2005, 5:38 am
what is rss? if someone could provide a tut on using rss i would really appreciate it lots. thanks

yfs1
Jan 6th 2005, 5:43 am
There isn't much to it. As it pertains to this thread, it allows you to put ever changing content on your page with no maintenance. Just choose a topic (there are millions) and there you go.

I have an example at my directory (http://www.kwikgoblin.com).

If you were to visit tommorow, the news stories would be different.

DangerMouse
Jan 7th 2005, 4:04 am
what is rss? if someone could provide a tut on using rss i would really appreciate it lots. thanks
An RSS (Really Simple Syndication / RDF Site Summary depending on who you're speaking to) tutorial can be found here (http://www.oreillynet.com/pub/a/network/2000/08/25/magazine/rss_tut.html)

yfs1
Jan 7th 2005, 4:23 am
An RSS (Really Simple Syndication / RDF Site Summary depending on who you're speaking to) tutorial can be found here (http://www.oreillynet.com/pub/a/network/2000/08/25/magazine/rss_tut.html)
Thanks for that Danger...I will say though, I posted my original post because of a frustration of trying to decipher some of these tutorials. ost newbies eyes will glaze over after two lines of that so I just figured I would give a cut and paste solution.

By the way, if you used my code please give me a rating (the little scales) with a comment. This will just let me know for the future if these type of things are usefull to people. In other words, if the feedback is good, I will post more like this.

Thanks again Danger - By the way even the fact that RSS means Really Simple Syndication is a matter of debate.

Cheers

DangerMouse
Jan 7th 2005, 6:36 am
Thanks for that Danger...I will say though, I posted my original post because of a frustration of trying to decipher some of these tutorials. ost newbies eyes will glaze over after two lines of that so I just figured I would give a cut and paste solution.

Let me tell you... It IS greatly appreciated!

Unfortunately I can't use it though as my host doesn't allow me to use an outgoing port 80 connection (they say it's for security reasons - I've never heard of any!) unless you email them and asl... So I currenty use a little VB app to pull in the rss and build my pages on a local machine before I publish them - it's messy but does work + get you get the speed benefits of having it on a flat html page.

By the way even the fact that RSS means Really Simple Syndication is a matter of debate.

Yeah - I heard a third def. today as well... for those wondering wtf I'm talking about. Here are the 3 definitions (I've heard) of RSS...

1) Really Simple Syndication
2) Rich Site Syndication
3) RDF Site Syndication

Anyway, it's a format / standard for syndicating content. Easy to read, easy to integrate. NICE ;)

Thewormman
Jan 7th 2005, 11:55 am
yfs1

I'm using your random script on a PHP dynamically generated page, and have found that if your script tries to load a feed where there is no output, at the time of the request, from the feed supplier, it just makes the whole page hang and not load.

Any ideas how I can get round this?

Many thanks

miko67
Jan 7th 2005, 5:47 pm
seems like a great "kiss" operation - thx a lot yfs1. Gonna try that real soon...

oh, and by all means keep'em comming if you can. This is the stuff that good forums are made of.

crafty
Jan 7th 2005, 6:34 pm
Thanks for all the information YSFI and Danger.
I love the cut and paste idea, but still not happening for me unfortunately but am determined to get it up and running one way or another.
(...I am in australia so you may have to print upside down for me to comprehend!!)
Went crosseyed reading the php tutorial.
My hosting details below may reveal something to you intelligent people :
Host server is running php version 4.3.9, on Apache/1.3.33 (Unix) mod_auth_passthrough/1.8 mod_log_bytes/1.2 mod_bwlimited/1.4 PHP/4.3.9 FrontPage/5.0.2.2634a mod_ssl/2.8.22 OpenSSL/0.9.7a server software.

Have asked host if port 80 problem may be it as suggested by D/M but no response as yet.
Incidently, Danger, I note that you may be a horse racing fan. Great site down here is
aapracingandsports.com.au/racing/index.asp
Their Neural Algorythms (free) are very popular with people doing their own ratings.

Thanks
Tony

mxlabs
Jan 7th 2005, 8:06 pm
I use rss feeds myself, works great.
can you explain the difference between "straight" and "rotating" rss feed? do you rotate similar rss feeds from other sites to make the page look dynamic or do you simply update the rss feeds?

yfs1
Jan 8th 2005, 3:53 am
I use rss feeds myself, works great.
can you explain the difference between "straight" and "rotating" rss feed? do you rotate similar rss feeds from other sites to make the page look dynamic or do you simply update the rss feeds?

Those are just my words for lack of a better term.

The straight feed is just one feed (as you will notice in the code) and is best suited when you want to be sure the visitor sees the same feed every time they come to that page.

The rotating can incorporate a unlimited amount of feeds and just picks one of the many you designate each time. I am currently using this on my directory site in order for there to be "different content" on each subpage of my directory. When the bots visit each individual page it is never more than 10% alike. The only drawback to this is a visitor may see two things they like in a particular feed and when they try to go back to view the second, they won't be able to find it without reloading over and over.

I am currently developing a solution to that however whcih I will post when done.

Wormman - Can you PM me the feed that is causing the issue so I can recreate it?

Cheers

yfs1
Jan 8th 2005, 3:59 am
Try a sample php test file that prints hello just to test that PHP is working. If that is successful then the likely culprit as mentioned before would be the port 80 issue.

Just a side note, although this works with my regular provider, as a test I opened a cheap go daddy account and it works perfect with no modification (for me anyway). I don't particularly like go daddy but if it can work there, any competent host should be able to set it correctly to view.

Also - If you are running html pages, it may seem obvious, but be sure your host actually has php enabled. They may list what version is available in their documentation but may not have it enabled for your account.

Hope that helps

Thanks for all the information YSFI and Danger.
I love the cut and paste idea, but still not happening for me unfortunately but am determined to get it up and running one way or another.
(...I am in australia so you may have to print upside down for me to comprehend!!)
Went crosseyed reading the php tutorial.
My hosting details below may reveal something to you intelligent people :
Host server is running php version 4.3.9, on Apache/1.3.33 (Unix) mod_auth_passthrough/1.8 mod_log_bytes/1.2 mod_bwlimited/1.4 PHP/4.3.9 FrontPage/5.0.2.2634a mod_ssl/2.8.22 OpenSSL/0.9.7a server software.

Have asked host if port 80 problem may be it as suggested by D/M but no response as yet.
Incidently, Danger, I note that you may be a horse racing fan. Great site down here is
aapracingandsports.com.au/racing/index.asp
Their Neural Algorythms (free) are very popular with people doing their own ratings.

Thanks
Tony

ferret77
Jan 8th 2005, 6:04 am
I created basically the same thing except it takes the rss feeds from a .txt file

so I could put hundreds of them in there

the link is my sig

yfs1
Jan 8th 2005, 6:29 am
Thanks for the add feret. Certainly if you are rotating more than 5 ads that would be the way to go. Its also nice if you are adding to a lot of pages as its just an include.

Interesting site, I see you arent a big Robert Novak fan :D

I created basically the same thing except it takes the rss feeds from a .txt file

so I could put hundreds of them in there

the link is my sig

ferret77
Jan 8th 2005, 7:19 am
yeah I don't like him but I can't help watching him some sort of morbid fascination

DangerMouse
Jan 10th 2005, 2:01 am
Incidently, Danger, I note that you may be a horse racing fan. Great site down here is...

Thanks crafty, I'm checking that out now... ;)

yfs1
Jan 10th 2005, 2:22 am
I didn't forget you wormman - I am looking into how to treat the "Make your own Feed" that you sent me. I didn't realize that existed.

Cheers

yfs1

I'm using your random script on a PHP dynamically generated page, and have found that if your script tries to load a feed where there is no output, at the time of the request, from the feed supplier, it just makes the whole page hang and not load.

Any ideas how I can get round this?

Many thanks

Thewormman
Jan 10th 2005, 5:25 am
I didn't forget you wormman - I am looking into how to treat the "Make your own Feed" that you sent me. I didn't realize that existed.

Cheers

No problem, one thing I have learn't from SEO is patience...patience...

Anyway it isn't costing me anything so when you can is fine :D

crafty
Jan 10th 2005, 6:46 am
Thanks YSFI, Danger and others.

I am making some progress .....at last.
I can get feeds going o/k as you suggest YSFI but I have to rename pages .php
instead of .html
Is there a simple solution to this?
many thanks
Tony

DangerMouse
Jan 10th 2005, 7:10 am
.htaccess file in the root of you web folder and add this line to it.

AddType application/x-httpd-php .php .htm .html

This will server pass all of your html files and will slow you down... I'm not sure how you make it server pass 1 file? Anyone else?

crafty
Jan 10th 2005, 3:50 pm
Thanks Danger
Slowing down is a bit of a problem.....I feel the need for speed!
My host has provided the following reply to setting things up so that it could be used on html pages:

"I would have to change server configuration for everyone so I'll have to give that some thought before agreeing to do so. In the mean time, saving a few pages that require the php extensions is a pretty easy thing to do and you will have to stick with that method until I can research how this might effect my other customers."

I appreciate all your assistance
Tony

yfs1
Jan 11th 2005, 1:05 am
If my hosting provider gave me a BS reason like that, I would change providers. There is so much competetion today you can easily find a host that will do what is a very simple and accepted practice.

Don't accept your web host telling you to come up with a workaround. You pay them!

Instead tell them if they are unwilling to do it then you will be required to change hosts. Its your site so take control!

I always see replies like this as unprofesional and they are probably going to be a problem with other things as your site grows.

Thanks Danger
Slowing down is a bit of a problem.....I feel the need for speed!
My host has provided the following reply to setting things up so that it could be used on html pages:

"I would have to change server configuration for everyone so I'll have to give that some thought before agreeing to do so. In the mean time, saving a few pages that require the php extensions is a pretty easy thing to do and you will have to stick with that method until I can research how this might effect my other customers."

I appreciate all your assistance
Tony

crafty
Jan 11th 2005, 9:23 pm
Thanks to you all it looks like I am up and running
see note just received from host below:
Very grateful to forum members for your help.
Tony

"SSI is enabled on your server. Test file below. If you see a couple dates - it's working
I've also changed server settings so you no longer need to name a page with the php extension."

dakar
Jan 13th 2005, 7:49 am
Just tagging.... want to give the php method a whirl... looks like it'd be better than the python method I have in place now.

DangerMouse
Jan 13th 2005, 8:20 am
"SSI is enabled on your server. Test file below. If you see a couple dates - it's working
I've also changed server settings so you no longer need to name a page with the php extension."

Careful of that crafty, it sounds like they've set your server up to server pass all html pages - this WILL slow down you pages, even the one's without any php code...

Trance-formation
Jan 13th 2005, 8:44 am
I just added my blog RSS feed to my homepage using Magpie RSS. Still needs some tweaks if I want descriptions but I have the titles and links at least. :)
I've just tweaked magpie to show descriptions, and to truncate them if they are too long.

The only problem I had with magpie is that the code they suggest (in the cookbook) to limit the number of news items is wrong... if you need the error pointing out, mail me because I haven't got the code here, but it's a simple error

Refrozen
Jan 13th 2005, 9:32 pm
I haven't had a feed I couldn't use yet. If you want to post some feeds I will try them for you (I am a trial and error kind of person).

You can check out the rotating feed on my directory:
www.kwikgoblin.com

It is around 2-3 weeks old and got a PR3.

I believe however the rotating content has helped by encouraging Google to keep indexing. Google added 22 pages from day 7 to 14. Hopefully that keeps growing exponentially.

I'm still experimenting with the feed code on that site (the format), so if it is down for 2-3 minutes it is because I am working on it.
What feeds are you using for the news on kwikgoblin. My website (www.refrozen.com) has an RSS feed for world news, but, all it really is is a compilation of other feeds so I am interested.

yfs1
Jan 14th 2005, 1:16 am
What feeds are you using for the news on kwikgoblin (http://www.kwikgoblin.com). My website (www.refrozen.com) has an RSS feed for world news, but, all it really is is a compilation of other feeds so I am interested.

I am using the ones I give in my example for my main page. There are literally millions of feed at www.syndic8.com (plus I believe you can submit yours)

Just be careful to look closely at them by clicking the RSS button as there are some crap ones there. I use the search functionality to get the subject I want.

Does someone have a PHP addition to my code to limit the amount of results listed (as mentioned earlier). There are a few good feeds I would like to use but they are so big by the end of the day. I prefer to not display more than 5 or so.

Cheers
PS. Thanks for the good feedback so far (reputation) on this thread. I will be sure to post more cut and paste stuff.

Trance-formation
Jan 14th 2005, 5:48 am
Does someone have a PHP addition to my code to limit the amount of results listed (as mentioned earlier). There are a few good feeds I would like to use but they are so big by the end of the day. I prefer to not display more than 5 or so.


Magpie RSS (http://magpierss.sourceforge.net/) uses an array to hold the data and then uses array slice to limit the number displayed

$num_items = 10;
$rss = fetch_rss($url);

$rss->items = array_slice($rss->items, 0, $num_items);

I'm not up to your level of coding so I don't know if that is any help:)

TwisterMc
Jan 14th 2005, 10:52 am
Magpie RSS (http://magpierss.sourceforge.net/) uses an array to hold the data and then uses array slice to limit the number displayed

$num_items = 10;
$rss = fetch_rss($url);

$rss->items = array_slice($rss->items, 0, $num_items);

I'm not up to your level of coding so I don't know if that is any help:)

I was wondering how you do that. I did it differently, however yours is better.

crafty
Jan 14th 2005, 4:45 pm
Thanks for the tip Danger.
I have not noticed any difference in loading times but you could be right.
( Are you backing any winners?)
Agree with what ysfi says re feeds at syndic8 .
Plenty from which to choose but also plenty of crap.
Only consider feeds that have some sort of a track record as some seem to "fall off the perch" pretty quickly while others are updated infrequently.
Cheers
Tony

Trance-formation
Jan 15th 2005, 5:01 am
I was wondering how you do that. I did it differently, however yours is better.
array_slice is smart enough to do the right thing if the $num_items is greater than the actual number of items:)

dirtdog1960theone
Feb 14th 2005, 9:20 am
Reading older posts I think I am going to give this a try. I use rss feeds on my My Yahoo and like them. I am going to see if I can make them work on one of my sites. http://forums.digitalpoint.com/images/icons/icon14.gif

wendydettmer
Feb 14th 2005, 11:04 pm
The lil php thing kicks BUTT, i LOVE it.

I just wish i knew ANYTHING about php, because I woudlnt' mind editing it to only show a certain number of results. But it's a neat lil thing :)

CanadianEh
Feb 15th 2005, 12:27 pm
Some good info. Just wondering if using your PHP code produces a version of the feed that can be spidered by the search engines.

yfs1
Feb 15th 2005, 1:42 pm
Some good info. Just wondering if using your PHP code produces a version of the feed that can be spidered by the search engines.

Absolutely, I actually bring in vistors on one of my sites where I rank for keyword phrases (sometimes strange) that are a combination of static content and the content of the feed that particular day

Good Luck and post back if the code was helpful!

CanadianEh
Feb 15th 2005, 1:53 pm
Awesome. I had gotten a bunch of feeds working but the static content can be a big plus. Thanks for the quick and helpful response.

saintdw
Feb 24th 2005, 4:24 am
$int = 0;
while ($int != 3){
$data = fread($fp, 4096);
xml_parse($xml_parser, $data, feof($fp))
or die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));

$int++;
}
fclose($fp);

xml_parser_free($xml_parser);

This line of code. In while loop if you change i != 1 it will show 4 things, i!=2 it will show 8 things, etc, etc.

I dont know yet how to break it up into less. When i have time ill try to pull the data and instead of parsing it, slap it into array and then print the number of items needed.

CanadianEh
Feb 24th 2005, 8:06 am
yfs1

Very nice script. Thank you for sharing it.

sifuhall
Feb 24th 2005, 2:35 pm
I think this is fantastic and I thank you very much for sharing this.

However, I must point out for those of you that place importance on having your pages validate that this is not valid html.

It appears the opening and closing dl tags are missing.

Please correct me if I am wrong on that, and thanks again for posting this.

fryman
Feb 24th 2005, 2:50 pm
Quick question:
Will this thing add new pages to your site? Or is is just some kind of window showing news from other sites?

Jim bob 9 pants
Feb 24th 2005, 2:59 pm
Thank you so much, I have been busting my bollocks trying to do this over the last few days, your a star!!!!!!!!!!!!!!

sifuhall
Feb 24th 2005, 3:38 pm
Quick question:
Will this thing add new pages to your site? Or is is just some kind of window showing news from other sites?


it adds content to existing pages

yfs1
Feb 25th 2005, 2:37 am
You can also create your own RSS Feeds, put them on your other sites and instantly have fresh content by only changing one feed.

You can further take advantage by using this technique with the rotating code so if you implore it sitewide, Google will always see changing content.

Also keep in mind you can control where the links go so if you have one site you really want to promote that month, you can do it with 5 minutes work.

Cheers and I am glad to hear so many have found this useful. Thanks to those who have added to it. If someone changes to code to limit the amount displayed to 5, please post it in its entirety (Don't post: change this to this...Its much more useful to have all the code so you can just cut and paste)

Cheers

Thewormman
Feb 27th 2005, 12:08 pm
$int = 0;
while ($int != 3){
$data = fread($fp, 4096);
xml_parse($xml_parser, $data, feof($fp))
or die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));

$int++;
}
fclose($fp);

xml_parser_free($xml_parser);

This line of code. In while loop if you change i != 1 it will show 4 things, i!=2 it will show 8 things, etc, etc.

I dont know yet how to break it up into less. When i have time ill try to pull the data and instead of parsing it, slap it into array and then print the number of items needed.

Could you show this mod as the whole code so I can see exactly how it is modified?

Thanks

saintdw
Feb 27th 2005, 12:24 pm
<?php
$insideitem = false;
$tag = "";
$title = "";
$description = "";
$link = "";
$locations = array('http://michaelthompson.org/news/goo-world.xml', 'http://forums.seochat.com/external.php', 'http://michaelthompson.org/news/goo-world.xml');
srand((float) microtime() * 10000000); // seed the random gen
$random_key = array_rand($locations);
function startElement($parser, $name, $attrs) {
global $insideitem, $tag, $title, $description, $link;
if ($insideitem) {
$tag = $name;
} elseif ($name == "ITEM") {
$insideitem = true;
}
}
function endElement($parser, $name) {
global $insideitem, $tag, $title, $description, $link;
if ($name == "ITEM") {
printf("<dt><b><a href='%s' target=new>%s</a></b></dt>",
trim($link),htmlspecialchars(trim($title)));
printf("<dt>%s</dt><br><br>",htmlspecialchars(trim($description)));
$title = "";
$description = "";
$link = "";
$insideitem = false;
}
}
function characterData($parser, $data) {
global $insideitem, $tag, $title, $description, $link;
if ($insideitem) {
switch ($tag) {
case "TITLE":
$title .= $data;
break;
case "DESCRIPTION":
$description .= $data;
break;
case "LINK":
$link .= $data;
break;
}
}
}
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
$fp = fopen($locations[$random_key], 'r')
or die("Error reading RSS data.");
$int = 0;
while ($int != n){
$data = fread($fp, 4096);
xml_parse($xml_parser, $data, feof($fp))
or die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));

$int++;
}
fclose($fp);

xml_parser_free($xml_parser);

?>

n in while loop number to be changed. At n=3+ It will display all things, n =1 will display 1-4 things ( depends on feed), 2 will display 5-9 things.

Vikkeedee
Feb 27th 2005, 12:40 pm
Thanks for the info ...

Thewormman
Feb 28th 2005, 2:21 am
EXCELLENT Saintdw

Thanks very much!!!!!!!!!!!!! :D

yfs1
Feb 28th 2005, 2:48 am
Great add - I would give you a positive for that add but I seemed to have already given you one - Great Work!

saintdw
Feb 28th 2005, 7:23 am
My pleasure :)

Was pretty simple, i want to do it so i can control the number of items displayed completely but i dont have time to look into that right now =\

Diamondbacks
Feb 28th 2005, 7:27 am
My pleasure :)

Was pretty simple, i want to do it so i can control the number of items displayed completely but i dont have time to look into that right now =\If I only wanted to display one feed location what would I need to change to make it work? :confused:

saintdw
Feb 28th 2005, 7:44 am
Let me play with it a little and ill post when it works

saintdw
Feb 28th 2005, 8:36 am
<?php
$insideitem = false;
$tag = "";
$title = "";
$description = "";
$link = "";
$locations = array('http://michaelthompson.org/news/goo-world.xml');
srand((float) microtime() * 10000000); // seed the random gen
$random_key = array_rand($locations);
function startElement($parser, $name, $attrs) {
global $insideitem, $tag, $title, $description, $link;
if ($insideitem) {
$tag = $name;
} elseif ($name == "ITEM") {
$insideitem = true;
}
}
function endElement($parser, $name) {
global $insideitem, $tag, $title, $description, $link;
if ($name == "ITEM") {
printf("<dt><b><a href='%s' target=new>%s</a></b></dt>",
trim($link),htmlspecialchars(trim($title)));
printf("<dt>%s</dt><br><br>",htmlspecialchars(trim($description)));
$title = "";
$description = "";
$link = "";
$insideitem = false;
}
}
function characterData($parser, $data) {
global $insideitem, $tag, $title, $description, $link;
if ($insideitem) {
switch ($tag) {
case "TITLE":
$title .= $data;
break;
case "DESCRIPTION":
$description .= $data;
break;
case "LINK":
$link .= $data;
break;
}
}
}
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
$fp = fopen($locations[$random_key], 'r')
or die("Error reading RSS data.");
$int = 0;
while ($int != n){
$data = fread($fp, 1024);
xml_parse($xml_parser, $data, feof($fp))
or die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));

$int++;
}
fclose($fp);

xml_parser_free($xml_parser);

?>

n in while loop number to be changed.

Here's a quick fix or something.

n= 1 --- 1 item displayed
n= 2 && fread($data, 256*3) --- 2 items displayed
n= 2 --- 3 items displayed
n= 3 --- 5 items displayed
n= 4 --- 7 items displayed

Not really a php expert, but to get the desired number of feeds you will needs to play around with 2 numbers:
N and the number in fread just under N

number in fread can be a multiple of 512, 1024... etc.

Play around with them until the desired number of items is displayed

saintdw
Feb 28th 2005, 8:38 am
If you dont want the links you can further edit $data and remove <link></link> if you know php good enough and then just echo the data.

saintdw
Feb 28th 2005, 8:47 am
also, those numbers i tested only with the feed included in the code.

If you use another feed you will probably have to pick new numbers to achieve the same amount of items displayed.

Thewormman
Mar 2nd 2005, 4:56 pm
OK
Nice to be able to contribute to this :D
Made a small addition in BOLD that will add the new 'no follow' attribute to all the links to the news items.

This means you will not pass your PR to people like CNN who really don't need it!
<?php
$insideitem = false;
$tag = "";
$title = "";
$description = "";
$link = "";
$locations = array('http://michaelthompson.org/news/goo-world.xml');
srand((float) microtime() * 10000000); // seed the random gen
$random_key = array_rand($locations);
function startElement($parser, $name, $attrs) {
global $insideitem, $tag, $title, $description, $link;
if ($insideitem) {
$tag = $name;
} elseif ($name == "ITEM") {
$insideitem = true;
}
}
function endElement($parser, $name) {
global $insideitem, $tag, $title, $description, $link;
if ($name == "ITEM") {
printf("<dt><b><a href='%s' target='new' rel='nofollow'>%s</a></b></dt>",
trim($link),htmlspecialchars(trim($title)));
printf("<dt>%s</dt><br><br>",htmlspecialchars(trim($description)));
$title = "";
$description = "";
$link = "";
$insideitem = false;
}
}
function characterData($parser, $data) {
global $insideitem, $tag, $title, $description, $link;
if ($insideitem) {
switch ($tag) {
case "TITLE":
$title .= $data;
break;
case "DESCRIPTION":
$description .= $data;
break;
case "LINK":
$link .= $data;
break;
}
}
}
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
$fp = fopen($locations[$random_key], 'r')
or die("Error reading RSS data.");
$int = 0;
while ($int != n){
$data = fread($fp, 1024);
xml_parse($xml_parser, $data, feof($fp))
or die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));

$int++;
}
fclose($fp);

xml_parser_free($xml_parser);

?>

Also I am getting this

XML error: junk after document element at line 1

Turning up at the bottom of some of my feeds and it is slowing the page loading a LOT

Anyone know how to get rid?

Thanks

dirvish
Mar 3rd 2005, 10:44 pm
If you don't want to mess with any programming and want to go from an RSS feed to html I recommend RSS Digest: http://www.bigbold.com/rssdigest/

If you just want to copy and paste some PHP, try out this script: http://www.feedforall.com/free-php-script.htm

yfs1
Mar 4th 2005, 1:36 am
Why would they use your script and give you a link when there is a perfectly good one here with no strings attached??

You are urging people to not use the one provided totally free here basically by calling it programming when you are giving a link to essentially the same code.

dirvish
Mar 4th 2005, 8:09 am
Why would they use your script and give you a link when there is a perfectly good one here with no strings attached??

You are urging people to not use the one provided totally free here basically by calling it programming when you are giving a link to essentially the same code.

Didn't mean to offend and I wasn't looking for a link. Just providing a couple alternatives...

CanadianEh
Mar 9th 2005, 9:13 am
OK
Nice to be able to contribute to this :D
Made a small addition in BOLD that will add the new 'no follow' attribute to all the links to the news items.

This means you will not pass your PR to people like CNN who really don't need it!
<?php
$insideitem = false;
$tag = "";
$title = "";
$description = "";
$link = "";
$locations = array('http://michaelthompson.org/news/goo-world.xml');
srand((float) microtime() * 10000000); // seed the random gen
$random_key = array_rand($locations);
function startElement($parser, $name, $attrs) {
global $insideitem, $tag, $title, $description, $link;
if ($insideitem) {
$tag = $name;
} elseif ($name == "ITEM") {
$insideitem = true;
}
}
function endElement($parser, $name) {
global $insideitem, $tag, $title, $description, $link;
if ($name == "ITEM") {
printf("<dt><b><a href='%s' target='new' rel='nofollow'>%s</a></b></dt>",
trim($link),htmlspecialchars(trim($title)));
printf("<dt>%s</dt><br><br>",htmlspecialchars(trim($description)));
$title = "";
$description = "";
$link = "";
$insideitem = false;
}
}
function characterData($parser, $data) {
global $insideitem, $tag, $title, $description, $link;
if ($insideitem) {
switch ($tag) {
case "TITLE":
$title .= $data;
break;
case "DESCRIPTION":
$description .= $data;
break;
case "LINK":
$link .= $data;
break;
}
}
}
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
$fp = fopen($locations[$random_key], 'r')
or die("Error reading RSS data.");
$int = 0;
while ($int != n){
$data = fread($fp, 1024);
xml_parse($xml_parser, $data, feof($fp))
or die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));

$int++;
}
fclose($fp);

xml_parser_free($xml_parser);

?>

Also I am getting this

XML error: junk after document element at line 1

Turning up at the bottom of some of my feeds and it is slowing the page loading a LOT

Anyone know how to get rid?

Thanks
Thanks for the usefull addition. I get the same XML error. The error goes away when I decrease "n" sufficiently.

saintdw
I know next to nothing about PHP, but it looks like you get XML error whenever you try to display more items than there are available for the feed(e.g. n is too high). Your addition needs something to to exit the loop in order to complete it.

saintdw
Mar 9th 2005, 9:46 am
Thanks for the usefull addition. I get the same XML error. The error goes away when I decrease "n" sufficiently.

saintdw
I know next to nothing about PHP, but it looks like you get XML error whenever you try to display more items than there are available for the feed(e.g. n is too high). Your addition needs something to to exit the loop in order to complete it.


Cant say im a php expert my self.

My addition is focused on limiting the number of items displayed havent tested it with large n numbers.

If you want everything displayed then the original works great :)

noppid
Mar 9th 2005, 10:13 am
Does this code cache the feed or hit the feed everytime someone displays a page using this code?

You should really read this... http://www.kbcafe.com/rss/rssfeedstate.html

There are alot of guidlines to help keep your app from being a "problem" reader you may want to consider.

CanadianEh
Mar 9th 2005, 2:36 pm
Hi yfs1

Thanks again for the script. Is there a way of displaying 2 separate feeds on the same page?

tfbpa
Mar 20th 2005, 5:38 am
Exactly what I needed and was looking for, works like a charm!
Thank You yfs1 !!

Lorem Ipsum
Mar 20th 2005, 8:51 pm
I was able to get this started on our site as well - thanks for the code. For one feed I pulled, I got the following error:

XML error: not well-formed (invalid token) at line 41

This was the code from line 41:

$link .= $data;


This error did not show up with the original two feeds listed in this thread. Any idea how I might go about straightening this out? Could this be a problem on the publisher's end? (BTW, if there were a step before 'newbie' in php coding, I'd be there - so please go easy on me).


Hmmm....discovered something else - presented on it's own page, it seems to work fine, other than the error noted above. But pasted into an existing php page, and it takes over, and no other content on the page is viewable. I'm certain that I'm goofing it up on my end, just not sure how to go about figuring out how. Any help is appreciated.


And on a funny note - went to pull a feed from a certain site, and sure enough, the feed included an article I had written for another site. :)

nevetS
Mar 20th 2005, 11:46 pm
Are you sure the error is on line 41 of your code? (As opposed to line 41 in an included class file?) Just a thought. I'm late to this thread.

Texacola
Mar 21st 2005, 12:03 am
Works very well! Thanks to all that contributed to this RSS thread, it's helped me loads. Now to find a darn feed that is even remotely related to inkjet cartridges, printers and toner that isn't a blatant advertisement of one of my opposition.

edit* And it does break the heck out of html validation too! Would this cause any of the search engines to ignore the sites?

I've added one to a couple of places to my site http://www.outofinkandtoner.com.au and would hate for Google (whenever the heck I get out of the sandbox) to penalise me for "bad code"!

Lorem Ipsum
Mar 21st 2005, 10:01 am
nevetS - It is entirely possible that the error is not on my side. Unfortunately, I don't have the knowledge to troubleshoot the issue.

nevetS
Mar 21st 2005, 11:30 am
Usuallly, php will report the error:

Error in file.php line 41.

Keep in mind that line 41 to you isn't necessarily line 41 to php. Usually what I do when the error is not obvious, is copy my original file over to a backup, then try to strip some earlier code out of the equation so I can narrow down the problem. Another method is to put a couple of <? echo "I got here without a problem";?> lines. I believe that when php counts lines, it counts them after the includes - so if there are 50 lines in your first include, then it would be in line 41 of that file.

I'm not very sure of myself right now (just woke up), but it's at least something to look into.

Padawan
Mar 22nd 2005, 6:27 pm
Say, for example, you are using a world news feed, is there any way to save the data each time the feed updates, so as to be able to build up an archive from day to day ?

Texacola
Apr 3rd 2005, 7:36 pm
Say, for example, you are using a world news feed, is there any way to save the data each time the feed updates, so as to be able to build up an archive from day to day ?

Did you end up getting some sort of answer to this question Padawan as I'm extremely interested in the answer too?

noppid
Apr 3rd 2005, 7:43 pm
Did you end up getting some sort of answer to this question Padawan as I'm extremely interested in the answer too?

Save a few news feed links. You will find most are dead in a week to a month. Not much worth archiving. :/

TheWebJunkie
Apr 12th 2005, 4:56 pm
Ive tried adding rss feed to my site and i get this error

XML error: junk after document element at line 50

here my index page code


<?php
error_reporting(E_ALL);

require_once 'PHProxy.class.php';

$PHProxy = new PHProxy(isset($_GET['flags']) ? $_GET['flags'] : null);

if (isset($_GET['url']))
{
$PHProxy->start_transfer($_GET['url']);
echo $PHProxy->return_response();
exit();
}

if (isset($_GET['action'], $_GET['delete']) && $_GET['action'] == 'cookies')
{
$PHProxy->delete_cookies($_GET['delete']);
header("Location: $PHProxy->script_url?action=cookies");
exit();
}

if (isset($_POST['username'], $_POST['password'], $_POST['server'], $_POST['realm'], $_POST['auth_url']))
{
$PHProxy->request_method = 'GET';
$PHProxy->url_segments['host'] = $PHProxy->decode_url($_POST['server']);
$PHProxy->set_authorization($_POST['username'], $_POST['password']);
$PHProxy->start_transfer($_POST['auth_url']);
echo $PHProxy->return_response();
exit();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
<head>
<title>NoMoreLimits</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<link rel="stylesheet" type="text/css" href="style.css" media="all" />
<script src="javascript.js" type="text/javascript"></script>
</head>
<body>
<center><div class="smallfont">NoMoreLimits resides on a fast dedicated server provided by <a href="http://www.perfectsql.com" target="_blank">PerfectSQL</a></div><br><a href="http://www.nomorelimits.net/siterefer/sr_form.php" target="_blank"><b>Recommend this site to a mate!</b></a></center>
<div id="container">
<div id="menu"><a href="<?php echo $_SERVER['PHP_SELF'] ?>">URL Form</a> | <a href="?action=cookies">Manage Cookies</a></div>
<div class="title">NoMoreLimits</div>
<?php

if (isset($_GET['error']))
{
echo '<div class="error"><b>Error:</b> ' . $_GET['error'] . '</div>';
}

if (isset($_GET['action']))
{
if ($_GET['action'] == 'cookies')
{
$cookies = $PHProxy->get_cookies('COOKIE', false);

if (!empty($cookies))
{
echo '<table style="width: 100%">';
echo '<tr><td class="option" colspan="5"><a href="?action=cookies&delete=all">Clear All Cookies</a></td></tr>';
echo '<tr><td class="head">Name</td><td class="head">Domain</td><td class="head">Path</td><td class="head">Value</td><td class="head">Action</td></tr>';

for ($i = 0; $i < count($cookies); $i++)
{
$j = $i&1 ? ' class="shade"' : '';
echo "<tr><td$j>{$cookies[$i][0]}</td><td$j>{$cookies[$i][1]}</td><td$j>{$cookies[$i][2]}</td>"
. "<td$j>{$cookies[$i][3]}</td><td$j><a href=". '"?action=cookies&delete='. md5(implode('', $cookies[$i])) . '">delete</a></td></tr>';
}

echo '</table>';
}
else
{
echo '<div class="error">No cookies available.</div>';
}
}
else if ($_GET['action'] == 'auth' && isset($_GET['server'], $_GET['realm'], $_GET['auth_url']))
{
echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . '">';
echo '<input type="hidden" name="server" value="'. $_GET['server'] .'" />';
echo '<input type="hidden" name="realm" value="'. $_GET['realm'] .'" />';
echo '<input type="hidden" name="auth_url" value="'. $_GET['auth_url'] .'" />';
echo '<table style="width: 100%">';
echo '<tr><td colspan="2" class="option">Enter user name and password for <b>' . $_GET['realm'] . '</b> at <i>' . $PHProxy->decode_url($_GET['server']) . '</i></td></tr>';
echo '<tr><td width="30%" class="option">User name</td><td class="option"><input type="text" name="username" value="" /></td></tr>';
echo '<tr><td width="30%" class="option">Password</td><td class="option"><input type="password" name="password" value="" /></td></tr>';
echo '<tr><td colspan="2" style="text-align: center"><input type="submit" value="OK" /></td></tr>';
echo '</table>';
echo '</form>';
}
}
else
{
?>
<form name="proxy_form" method="get" action="<?php echo $_SERVER['PHP_SELF'] ?>">
<input type="hidden" name="url" value="" />
<input type="hidden" name="flags" value="" />
</form>
<form name="settings" method="get" action="" onsubmit="return submit_form();">
<table style="width: 100%">
<tr><td class="option" style="width: 20%">URL</td><td class="option" style="width: 80%">&nbsp;<input type="text" name="url" size="70" value="" /></td></tr>
<?php echo $PHProxy->options_list(true, true) ?>
</table>
<div style="text-align: center"><input type="checkbox" name="new_window" />New Window <input type="submit" name="browse" value="Browse" onclick="return submit_form();" /><input type="reset" value="Reset Form" /></div>
<div style="text-align: center"><a href="http://sourceforge.net/projects/poxy/">PHProxy</a> <?php echo $PHProxy->version ?> Copyright 2004 <a href="http://www.whitefyre.com/">ultimategamer00</a></div>
</form><br><p> Partner Links: <a href="http://www.talkpixar.com"><font color="#FF0000"><b>D</b></font></a><a target="_blank" href="http://www.talkpixar.com"><font color="#FF0000"><b>isney
Pixar forums</b></font></a><font color="#FF0000"></font></b></font> | <a href="http://www.babe-forum.com"><b>Babe Forum - Hot pics and chat</b></a> || <a href="http://www.sigtraders.com"><b>Sigtraders</b></a> || <a href="http://www.thejosher.com">TheJosher</a> || <a href="http://www.alldotnet.com/">All Dot Net Search Directory</a> || <?php include('http://www.globalfusion.com.au/linkhost.php'); ?> | <a href="http://www.yoga-for-health.net">Yoga</a> | <a href="http://www.jonwheatley.co.uk">Jon Wheatley</a>
</p>
<br>
<center><script type="text/javascript"><!--
google_ad_client = "pub-xxxxxxxxxxxxxxx";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text";
google_ad_channel ="";
google_color_border = "FF0000";
google_color_bg = "FFFF00";
google_color_link = "FF0000";
google_color_url = "0000FF";
google_color_text = "000000";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></center><br><?php
$insideitem = false;
$tag = "";
$title = "";
$description = "";
$link = "";
$locations = array('http://www.computerworld.com/news/xml/6/0,5009,,00.xml');
srand((float) microtime() * 10000000); // seed the random gen
$random_key = array_rand($locations);
function startElement($parser, $name, $attrs) {
global $insideitem, $tag, $title, $description, $link;
if ($insideitem) {
$tag = $name;
} elseif ($name == "ITEM") {
$insideitem = true;
}
}
function endElement($parser, $name) {
global $insideitem, $tag, $title, $description, $link;
if ($name == "ITEM") {
printf("<dt><b><a href='%s' target='new' rel='nofollow'>%s</a></b></dt>",
trim($link),htmlspecialchars(trim($title)));
printf("<dt>%s</dt><br><br>",htmlspecialchars(trim($description)));
$title = "";
$description = "";
$link = "";
$insideitem = false;
}
}
function characterData($parser, $data) {
global $insideitem, $tag, $title, $description, $link;
if ($insideitem) {
switch ($tag) {
case "TITLE":
$title .= $data;
break;
case "DESCRIPTION":
$description .= $data;
break;
case "LINK":
$link .= $data;
break;
}
}
}
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
$fp = fopen($locations[$random_key], 'r')
or die("Error reading RSS data.");
$int = 0;
while ($int != 6){
$data = fread($fp, 1024);
xml_parse($xml_parser, $data, feof($fp))
or die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));

$int++;
}
fclose($fp);

xml_parser_free($xml_parser);

?>
<?php
}

echo '</div></body></html>';
?>

Padawan
Apr 13th 2005, 6:11 pm
Did you end up getting some sort of answer to this question Padawan as I'm extremely interested in the answer too?

No, I didn't get an answer. What I did was copy the news each day to a new static web page and built up my own archive that way - not ideal but still helps build up some content quickly. :)

Jez
Apr 15th 2005, 1:56 am
Hi yfs1,

Thanks for this code! I have had great success on my blog with it http://www.hitfix.co.uk/blog it was just the answer I had been looking for for a while.

I have another question though that no one else seems to know how to fix :

I want to put your feed code onto a recip directory as an experiment - the pages get created by Arelis and all seems to work like a charm until Arelis adds the sub directory name to the RSS feed:

typically something like this in bold

<?php
$insideitem = false;
$tag = "";
$title = "";
$description = "";
$link = "";
function startElement($parser, $name, $attrs) {
global $insideitem, $tag, $title, $description, $link;
if ($insideitem) {
$tag = $name;
} elseif ($name == "ITEM") {
$insideitem = true;
}
}
function endElement($parser, $name) {
global $insideitem, $tag, $title, $description, $link;
if ($name == "ITEM") {
printf("<dt><b><a href='%s' target='new' rel='nofollow'>%s</a></b></dt>",
trim($link),htmlspecialchars(trim($title)));
printf("<dt>%s</dt><br><br>",htmlspecialchars(trim($description)));
$title = "";
$description = "";
$link = "";
$insideitem = false;
}
}
function characterData($parser, $data) {
global $insideitem, $tag, $title, $description, $link;
if ($insideitem) {
switch ($tag) {
case "TITLE":
$title .= $data;
break;
case "DESCRIPTION":
$description .= $data;
break;
case "LINK":
$link .= $data;
break;
}
}
}
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
$fp = fopen("http://news.search.yahoo.com/news/rss?ei=UTF-8&p=Sub Directory","r")
or die("Error reading RSS data.");
while ($data = fread($fp, 4096))
xml_parse($xml_parser, $data, feof($fp))
or die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
fclose($fp);
xml_parser_free($xml_parser);
?>

As you can see Arelis adds the sub directory name with a space and not a "+" and the yahoo search therefore doesn't recognise it.

My question is - is there a way to strip out the "space" and replace with "+" just in that line? Remember that after being created each page (or RSS feed code) will have a different sub directory name - perhaps something like "Cross Trainers UK" needing to be "Cross+Trainers+UK" - I don't know enough about php to know whether this is impossible or not.

I hope I have explained myself clearly!

Your reply would be appreciated if only to stop me timkering about with it to try to make it work if it's not possible.

Thanks,

Jez.

neterslandreau
Apr 15th 2005, 4:10 am
My question is - is there a way to strip out the "space" and replace with "+" just in that line? Remember that after being created each page (or RSS feed code) will have a different sub directory name - perhaps something like "Cross Trainers UK" needing to be "Cross+Trainers+UK" - I don't know enough about php to know whether this is impossible or not.

www.php.net/urlencode
www.php.net/urldecode

ZenithalRavage
May 5th 2005, 10:51 am
This code is great!
I can get it to work like a charm in it's own php page (www.a-base.dds.nl/forum/rsstest.php), but I'm trying to get it into a seperate vbulletin page without success at the moment (www.a-base.dds.nl/forum/news.php).

As you can see it seems like it's just echoing out the code or something, does anybody have a clue as how to get this to work?

dirtdog1960theone
May 6th 2005, 6:45 am
Did not work durn it. I cut and pasted the code into a test html page and uploaded it.

When I view the page I just see the code displayed.

First thing viewable:

%s", trim($link),htmlspecialchars(trim($title))); printf("
%s


",htmlspecialchars(trim

down to the last lline

xml_parser_free($xml_parser); ?>

Am doing soemthing incorrectly? I tried two differnet hosts.

Does this mean they don't enable php?

Thanks Dan

added just saw the post above, I named the file index.html do I have to give it a .php extension?

Texacola
May 6th 2005, 6:56 am
dirdog you probably will have to add the following to your .htaccess file, on a line by itself

AddType application/x-httpd-php .htm .html

google how to if not sure. It's what I had to do to get my php inside html to work

DangerMouse
May 6th 2005, 7:28 am
Was saying this to the poster above yours - sorry :$

I think he's trying to run it in a php page though: www.a-base.dds.nl/forum/news.php

Only thing I can think... Have you encapsulated the code in your <? php tags ?> ?

ZenithalRavage
May 6th 2005, 7:52 am
Was saying this to the poster above yours - sorry :$

I think he's trying to run it in a php page though: (www.a-base.dds.nl/forum/news.php)

Only thing I can think... Have you encapsulated the code in your <? php tags ?> ?
Hello,
yes the php tags are correct. It seems I can't just copy paste this whole code into this news template I made because I think it's conflicting with the existing vbulletin code but I have no idea how to solve this, my php knowledge is too limited for that :o
Maybe there are others here who have succesfully used this code on a vbulletin page?

mopacfan
May 6th 2005, 7:59 am
This thread, even do dealing with php, was very useful. I was able to find a good feed for my site and I also found a company with whom I can set up an affiliate program that will be perfectly suited for my site. Thanks YFS1

dirtdog1960theone
May 6th 2005, 8:39 am
dirdog you probably will have to add the following to your .htaccess file, on a line by itself

AddType application/x-httpd-php .htm .html

google how to if not sure. It's what I had to do to get my php inside html to work

Thanks Texacola. No I don't know how to do it. I don't see the .htaccess file from the ftp program so I am stumped.

Thanks DangerMouse. I don't know anything about the link in ZR's thread. My question was about the file extension I noticed ZR using php vs html.

I am assuming the errors are due to the hosting companies not enabling php <shrug>. I am going to email the two hosting companies I use and ask them about this code.

Anything else I should ask? Like adding AddType application/x-httpd-php .htm .html Texacloa mentioned?

One hosting company will start a series of mindless emails strings till they get the question to a tech, and then will want more money. :p
The other will ignore me until they are out of money. :rolleyes:

DangerMouse
May 6th 2005, 8:49 am
If there isn't already an .htaccess file there - try making one. it's just a text file - nothing else is needed other than this line

AddType application/x-httpd-php .htm .html

If that doesn't work... your host might not allow it... I would ask them anyway

Jez
May 6th 2005, 12:51 pm
www.php.net/urlencode
www.php.net/urldecode
__________________
Neters Landreau

Thanks Neters Landreau,

Unfortunately I still can't get it to work! :confused:

I will get there eventually I guess - I just need to know a little bit more than nothing at all about PHP!

I have passed it onto a friend with a little more knowledge than me - hopefully he will be able to implement the urlencode.

dirtdog1960theone
May 7th 2005, 8:08 am
dirdog you probably will have to add the following to your .htaccess file, on a line by itself

AddType application/x-httpd-php .htm .html

google how to if not sure. It's what I had to do to get my php inside html to work

Thanks did that. For anybody trying to get this to work I tried both:

AddHandler application/x-httpd-php .html .htm
AddType application/x-httpd-php .htm .html

The seems to start at or around the line

printf("<dt><b><a href='%s'>%s</a></b></dt>",

It creates an html link to my directory with the tag % sign as the link text.

prints out printf("<dt><b><a href='%s'>%s</a></b></dt>", and all text after that.

HostingInsider
May 7th 2005, 11:47 pm
My Blogger blog's RSS wouldn't work on the code that is listed at SitePoint, but my PHPBB RSS feed would.

letsmakeamillion
Jun 8th 2005, 4:45 am
Thanks for this BLOCKBUSTER tip. Been searching for how to implement this on my .html pages for MONTHS.

Just added a little to your rep points :)

yfs1
Jun 8th 2005, 4:59 am
Cheers,

Of course be sure to read this thread in its entirity (if you are using it) as there are different issues brought up. My post was merely to provide the code to do it. You can decide for yourself whether to implement it or not ;)

bentong
Jun 8th 2005, 5:00 am
thanks for the good resource..a great big help to all members wanted to start a feed.

Hodgedup
Jun 8th 2005, 10:48 am
Nice job yfs1 and everyone else that has provided enhancements.

I started reading the first page of the thread and I when I came to the terms "straight" and "rotating" rss feed. I typed "difference between rotating feed and straight feed" into Goggle and page 2 of the thread came up number 1. lol. I guess I should have just read through the entire thread first.

DangerMouse
Jun 13th 2005, 7:49 am
My Blogger blog's RSS wouldn't work on the code that is listed at SitePoint, but my PHPBB RSS feed would.

Blogger.com syndicates content to an ATOM feed - not RSS...

Maybe that's why it aint working?

jeremy860
Jun 24th 2005, 7:14 pm
thanks for the tutorial

Valtar
Jun 27th 2005, 2:54 pm
I just want to send out a Thanks to yfs1 and everyone else who posted useful information on RSS feeds, Thanks to you all I finally got a RSS feed going to my website. ;)

hmilesjr
Jun 29th 2005, 7:22 pm
I want to change my self edited "New Articles box" on my home page http://www.quoteforinsurance.com to an RSS feed to index new articles in my site. I have written everything in html thus far and I'm not keen on changing everything over to a data retrieval system.

Is it possible to do this? Or, should I setup a new page to list the feeds? Can I post standard html files in an RSS feed system? The more I read the more confused I am getting about this. Is what I want to do feasible?

Hubert

pcdoc
Jun 30th 2005, 1:24 pm
hmilesjr, sent ya a PM.

andylong
Jul 1st 2005, 9:12 am
Yeah, but trying to get a really good RSS feed for the advertising industry is a nightmare.

nlgordaz
Jul 1st 2005, 11:54 am
RssEqualizer works well. and it takes the feed out of java so it can be spidered.

theduke56789
Aug 26th 2005, 11:44 am
Saintdw, you mentioned there was a way to remove the links. Would you be kind enought to elaborate? Thanks

If you dont want the links you can further edit $data and remove <link></link> if you know php good enough and then just echo the data.
__________________

DangerMouse
Aug 26th 2005, 4:10 pm
Yeah, but trying to get a really good RSS feed for the advertising industry is a nightmare.

PM me if you're interested in putting together a new feed... We can scan about 1,000 news sources and would be happy to help ;)

Cheryl20772
Aug 27th 2005, 9:17 am
RssEqualizer works well. and it takes the feed out of java so it can be spidered.Yes, that is an option, but it is also an expensive one.

I have been searching for weeks now on this subject and hit a gold mine in the knowledgable people posting to this forum. Thanks to all of you! :)

My knowledge of php is nil; so I have not gotten more than js feed onto my pages yet. I found the free http://www.rss2html.com/ and haven't gotten it to work yet and now I have found this option and all the good advice here. I would love to be able to get this working without having to spend $97.

nlgordaz
Aug 29th 2005, 12:18 pm
cool man! great info.

nlgordaz
Sep 3rd 2005, 7:17 pm
Where do you insert the XML code?

guest
Sep 4th 2005, 5:58 am
Hi,

I downloaded rss20.php

set the database parameters and uploaded

But when i checked www.domain.com/rss20.php

all i see is

<?xml version="1.0" encoding="iso-8859-1" ?>
- <rss version="2.0">
<channel />
</rss>

I read that i should use add_channel function
Don't know how to add or from where to add

Please someone help me out with this.

Thanks

guest
Sep 6th 2005, 7:13 pm
Hi,

Can someone tell me what exact code should i have to use for biz directory and where exactly i should place the code in template_index.php file

I tried it but the results R being shown at the pages TOP and not at the bottom/fotter.



Hope someone helps..

guest
Sep 7th 2005, 7:26 am
NO ONE??

Strange...

Hope someone atleast this time will reply to help

yfs1
Sep 7th 2005, 7:35 am
I think it works better if you put it in index.php, not template_index.php

guest
Sep 7th 2005, 9:38 am
Will the results get displayed on all pages?

I tried in template_index.php but its displaying the matter on header/top part of the page.

yfs1
Sep 7th 2005, 11:17 am
Yes, add your code below

}else{
$replace = array("[CATEGORY_NAME]" => $current_category["name"]);
echo strtr($TEMPLATE["PAGES"]["NO_PAGES"],$replace);
};
};
echo $TEMPLATE["FOOTER"];
?>

on index.php and they will be site wide

guest
Sep 8th 2005, 12:14 am
@yfs1

Thanks alot for that information

hershel
Sep 29th 2005, 7:17 am
Thanks for the code - got it up on the site and working fine. I am using an rss feed from the BBC and each time you click on a link it takes you to their site. IS there anyway i can change the code so that it opens the content in a new window (this way my visitors will not leave the site every time they click ona news link)

Thanks

yfs1
Sep 29th 2005, 7:22 am
Thanks for the code - got it up on the site and working fine. I am using an rss feed from the BBC and each time you click on a link it takes you to their site. IS there anyway i can change the code so that it opens the content in a new window (this way my visitors will not leave the site every time they click ona news link)

Thanks

There is but you aren't supposed to do that. By using their feed you agree to link to the full story.

I have messed around with that myself in the past :cool: which reminds me I need to change that :p

SEbasic
Sep 29th 2005, 7:26 am
There is but you aren't supposed to do that. By using their feed you agree to link to the full story.He wan't the link to open in a new window - that's allowed (Although not a great user experience).

yfs1
Sep 29th 2005, 7:30 am
Sorry misread that

Yes you can do that if you like...Just set a blank target in the url just like you would on any link

See:
printf("<dt><b><a href='%s' target=new>%s</a></b></dt>",

You should be able to change it there

hershel
Sep 29th 2005, 7:39 am
Thanks guys - appreciate the help!

SoniaJr
Sep 29th 2005, 11:26 am
Hi
I recently introduced the RSS "technique" to my beloved customers activating the RSS Service on all my websites.
Do you think that besides the increased publicity because of our RSS subscribers, are there other benefits for enabling the RSS service? I mean, does that count for Google, MSN or the other important search engines?

worker
Nov 16th 2005, 8:12 pm
What do you think about daily press pop, I am using it for some time now, but can't say that it is so easy to manage the subscription everything needs to be done in hand, no automation, how about this in sindic8

worker
Nov 16th 2005, 8:13 pm
daily press pop do not have a requrement of linking back to the full article on to the short description or even link upon your choice

hima
Nov 16th 2005, 10:02 pm
Hi

I just want to know how to make my web page a RSS Feed so that the others can use it :confused:

Hmmm......What all i know abt RSS Feed is that we can copy and paste that specific (Clicking on XML button will give us the path) path in our web page that makes our page get that content

So Pls Help me in this matter

Thanks

steve_gts
Nov 24th 2005, 2:34 pm
Hi all,

Apologies for bringing this thread back up, but I recently asked a question about this and was pointed here. The code worked a treat and was so easy. however I think I'm making a fundamental mistake as when it all displays on the pages I am getting a load of html code showing after the actual news feed text, like this:

French report rejects plan to aid minorities
PARIS (Reuters) - A report drawn up for the French government has rejected calls for "positive discrimination" to help minorities find jobs, dealing a blow to Interior Minister and presidential hopeful Nicolas Sarkozy.<img src="http://feeds.feedburner.com/reuters/worldNews?g=5868"/>

Also It is displaying different news items to what is showing as their latest news items. I added the page URL to the code, should I be adding something different?

Thanks

BTW ysf1, your avatar is rather off putting because in my head I read all your posts in an Alan P voice!!!

latehorn
Dec 3rd 2005, 3:26 am
extremely usefull.. Thanks!!

latehorn
Dec 3rd 2005, 4:22 am
Also.. I addedrel='nofollow'in the A href tag to stop pagerank drain.

jmaduk
Dec 6th 2005, 10:37 pm
Here's a free site that allows you to create "custom RSS" feeds.

http://www.greatfreecontent.com allows you to add unique content to your site by creating a super feed from over 9000 feeds in the directory. You select which categories to include and how you want the feeds that you select to be displayed

Make sure to add your feeds to the directory.

Deano
Dec 27th 2005, 8:28 am
Apologies for bringing this thread back up, but I recently asked a question about this and was pointed here. The code worked a treat and was so easy. however I think I'm making a fundamental mistake as when it all displays on the pages I am getting a load of html code showing after the actual news feed text, like this:

French report rejects plan to aid minorities
PARIS (Reuters) - A report drawn up for the French government has rejected calls for "positive discrimination" to help minorities find jobs, dealing a blow to Interior Minister and presidential hopeful Nicolas Sarkozy.<img src="http://feeds.feedburner.com/reuters/worldNews?g=5868"/>

Also It is displaying different news items to what is showing as their latest news items. I added the page URL to the code, should I be adding something different?

Yeah i have a similar problem on a lot of feeds, I think that it is to do with the image file. I've just searched through lots of feeds to find ones that do not have images; this is very limiting.

If some one could tweak the code so that it displays images and only takes the first article in the feed it would be much appreciated :)

All I want for christmas is a new feed :)

dotcommakers
Dec 27th 2005, 8:40 am
great code mate..

i put it in a php page and works get but one problem is there

there is no actual image but just image code plz check following output

N.Korea's priority is ties with US -S.Korea
SEOUL (Reuters) - North Korea is more interested in establishing diplomatic ties with the United States than it is in receiving economic aid, a top South Korean official said on Tuesday. <p><a href="http://feeds.feedburner.com/~a/reuters/worldNews?a=73kyC5"><img src="http://feeds.feedburner.com/~a/reuters/worldNews?i=73kyC5" border="0"></img></a></p><img src="http://feeds.feedburner.com/reuters/worldNews?g=8832"/>

john_loch
Dec 27th 2005, 8:44 am
Sorry to post off topic Deano, but that site in your sig is just bloody hilarious !

The Dear Air 2000 stuff - I'm *still* chuckling as i type this :D

Cheers,

JL

Deano
Dec 27th 2005, 11:40 am
Sorry to post off topic Deano, but that site in your sig is just bloody hilarious !

The Dear Air 2000 stuff - I'm *still* chuckling as i type this


My dad will be pleased :)

He used to be a scriptwriter for the BBC, did the two Ronnies, Les Dawson, Ken Dodd etc.

The letters to the airlines are all genuine, he had to stop in the end as the FAA, were getting fed up of him wasting the airlines time!

colin008
Dec 27th 2005, 11:59 am
Works great, good scripting.

dynn
Dec 28th 2005, 4:27 am
Hello all, I wanted to be sure I always had fresh content on some of my sites so I started looking into RSS feeds but it was always way more complicated than it should have been.

Well after a few weeks of experimentation, I have the code for two scenarios:

1.) Add a straight RSS feed
2.) Add a rotating RSS feed

Just change the feed (it should be obvious where that is :) )

You can get just about any feed you can think about here: www.syndic8.com

For a Straight Feed

<?php
$insideitem = false;
$tag = "";
$title = "";
$description = "";
$link = "";
function startElement($parser, $name, $attrs) {
global $insideitem, $tag, $title, $description, $link;
if ($insideitem) {
$tag = $name;
} elseif ($name == "ITEM") {
$insideitem = true;
}
}
function endElement($parser, $name) {
global $insideitem, $tag, $title, $description, $link;
if ($name == "ITEM") {
printf("<dt><b><a href='%s'>%s</a></b></dt>",
trim($link),htmlspecialchars(trim($title)));
printf("<dt>%s</dt><br><br>",htmlspecialchars(trim($description)));
$title = "";
$description = "";
$link = "";
$insideitem = false;
}
}
function characterData($parser, $data) {
global $insideitem, $tag, $title, $description, $link;
if ($insideitem) {
switch ($tag) {
case "TITLE":
$title .= $data;
break;
case "DESCRIPTION":
$description .= $data;
break;
case "LINK":
$link .= $data;
break;
}
}
}
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
$fp = fopen("http://michaelthompson.org/news/goo-world.xml","r")
or die("Error reading RSS data.");
while ($data = fread($fp, 4096))
xml_parse($xml_parser, $data, feof($fp))
or die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
fclose($fp);
xml_parser_free($xml_parser);
?>

For a rotating feed:

<?php
$insideitem = false;
$tag = "";
$title = "";
$description = "";
$link = "";
$locations = array('http://michaelthompson.org/news/goo-world.xml', 'http://forums.seochat.com/external.php', 'http://michaelthompson.org/news/goo-world.xml');
srand((float) microtime() * 10000000); // seed the random gen
$random_key = array_rand($locations);
function startElement($parser, $name, $attrs) {
global $insideitem, $tag, $title, $description, $link;
if ($insideitem) {
$tag = $name;
} elseif ($name == "ITEM") {
$insideitem = true;
}
}
function endElement($parser, $name) {
global $insideitem, $tag, $title, $description, $link;
if ($name == "ITEM") {
printf("<dt><b><a href='%s' target=new>%s</a></b></dt>",
trim($link),htmlspecialchars(trim($title)));
printf("<dt>%s</dt><br><br>",htmlspecialchars(trim($description)));
$title = "";
$description = "";
$link = "";
$insideitem = false;
}
}
function characterData($parser, $data) {
global $insideitem, $tag, $title, $description, $link;
if ($insideitem) {
switch ($tag) {
case "TITLE":
$title .= $data;
break;
case "DESCRIPTION":
$description .= $data;
break;
case "LINK":
$link .= $data;
break;
}
}
}
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
$fp = fopen($locations[$random_key], 'r')
or die("Error reading RSS data.");
while ($data = fread($fp, 4096))
xml_parse($xml_parser, $data, feof($fp))
or die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
fclose($fp);
xml_parser_free($xml_parser);
?>


can i just copy and paste to my blog/website in order to run this script?

Deano
Dec 28th 2005, 9:08 am
yeah just post into your source, it works a treat :) (make sure that your page is php though, not htm!)

dynn
Dec 29th 2005, 6:21 pm
great and fantastic... i already try and it was successful...have a look www.dir2u.com and pls comment...

Deano
Dec 30th 2005, 2:02 pm
Hi Dynn, glad it worked for you.

I take it that your plan is to get more visitors to your website.

What I would recommend, is to use a seperate stream for each catergory.

eg if you had a stream related to widgets in the widgets section of the directory, then it would make the catergorary more relevant.

Also when people submit to directories they want as few links as possible, I would therefore reccommend that you linit the number of articles in each stream, to one or two.

If you do these two things I think that you'll have a nice directory what people would like to submit to.

Deano

dynn
Dec 30th 2005, 10:41 pm
Hi Dynn, glad it worked for you.

I take it that your plan is to get more visitors to your website.

What I would recommend, is to use a seperate stream for each catergory.

eg if you had a stream related to widgets in the widgets section of the directory, then it would make the catergorary more relevant.

Also when people submit to directories they want as few links as possible, I would therefore reccommend that you linit the number of articles in each stream, to one or two.

If you do these two things I think that you'll have a nice directory what people would like to submit to.

Deano

thanks your recommendations and advice....

best-p4u
Dec 31st 2005, 8:45 pm
great and fantastic... i already try and it was successful...have a look www.dir2u.com and pls comment...


where do you insert the code(phplinkdirectory)??

Moreover, it seems there are some mistakes:

e.g: html code(br,<a href="www.domain.name">.etc...) cann't show correctly.

I have also created a test page at:

http://download.best-p4u.com/rss_news.php

The result is the same.

Could someone help me!!

Thanks!!

Happy new year!!

:(

pcdoc
Jan 11th 2006, 8:28 am
Need guru help; script works nicely here

http://www.wilkes-nc-real-estate.com/

save for parsing of quote marks and other special characters replaced by

’, 20, 21, 30, etc.

TIA

which, after 2 hours of googling, Wordpress writes

http://www.ncrealestateblog.com/?feed=rss2

see page bottom

with the "un-parse-able" characters.

Wondering, if this can be patched in wp-rss2.php

Hmmm...

kichus
Jan 12th 2006, 9:01 pm
i tried copying the script (by yfs1) to my php page and i am getting an error: "Error reading RSS data.

can anyone help?

Thanks

MattEvers
Jan 12th 2006, 9:39 pm
i tried copying the script (by yfs1) to my php page and i am getting an error: "Error reading RSS data.

can anyone help?

Thanks

Did you set the links, title, etc.?

kichus
Jan 12th 2006, 10:00 pm
Did you set the links, title, etc.?

No I didn't. I just gave some new locations (I think that is links). How do I set title etc...

miko67
Jan 13th 2006, 1:22 am
You can get just about any feed you can think about here: www.syndic8.com (http://www.syndic8.com) Hehe, must be my lucky day. When I finally decide to try it out this website is "down". Must try again in a few minutes.

Do anybody have alternatives to www.syndic8.com (http://www.syndic8.com) ?

Jim_Westergren
Jan 13th 2006, 1:56 am
where do you insert the code(phplinkdirectory)??
phplinkdirectory uses a smarty engine, here was my solution for that:

http://www.jimwestergren.com/tutorial-rss-feed-inside-smarty-template-files/

devin
Jan 18th 2006, 8:34 am
i couldn't get syndic8 to work all morning too. :)

yfs1
Jan 18th 2006, 8:40 am
Its back up now ;)

miko67
Jan 18th 2006, 2:33 pm
Its back up now ;)Thx :cool:

I would green-rep you, but the system said "yfs1 has received too much rep in the last 24 hours" - so, sadly I wasn't able to :p - Maybe someone else can help out...?

samantha pia
Jan 20th 2006, 12:11 am
My dad will be pleased :)

He used to be a scriptwriter for the BBC, did the two Ronnies, Les Dawson, Ken Dodd etc.

The letters to the airlines are all genuine, he had to stop in the end as the FAA, were getting fed up of him wasting the airlines time!
oh god i wet myself 3 times and sprayed my screen with about 2 cups of coffee, Deano that was the best 3 hours i have had in years, it was so funny the air2000 letters, well worth the time. this was one that made me wet myself,
Aer Lingus Plc
Travelling with your airline recently I asked one of your charming stewardesses, Bridget I think her name was, what the 'Lingus' in the name Aer Lingus meant.....
I thought for a moment that it might be a suffix, but quickly discarded that idea as I only know one word which has Lingus as a suffix, and it can't possibly mean that, because although Aer Lingus is by no means the most impressive airline that I have ever flown with, it certainly doesn't suck......

reply
Thank you for your recent letter.

There's a very simple answer to your question. 'Aer Lingus' is an Irish phrase meaning, appropriately enough, air fleet. Initially in 1936, the company operated under the name 'Irish Sea Airways', but this was soon changed to Aer Lingus, which we have been operating under ever since.

reply
I assume that you changed the name of your airline from Irish Sea Airlines to Aer Lingus because you wanted to give it an Irish flavour. However Aer Lingus, which I am assuming is Gaelic, only makes sense to someone who speaks this obscure language. If you want to highlight the 'Irishness' of your airline, while at the same time making the name understandable to anyone who speaks English, the perfect appellation for it would be Aer O'Plane....

well worth a visit
:D

Kaediem
Jan 29th 2006, 1:07 pm
Thanks for this, it's just what I needed to have my latest blogs listed on the home page of my new site.

Wondering though if you could offer some help... I wanted to have the latest blogs to list the last 3 or 5 blogs with the title, date and a couple of lines of the blog. Is that possible with this code? Any assistance would be helpful and appreciated... the page I'm trying to do this on is

http://www.myrollercoasterkid.com

it's only a couple of days old and in the development stage so please ignore the "mess".

Thanks,

Lisa

ST12
Feb 2nd 2006, 9:43 am
I am not a pro in this, so I would appreciate any and all help.

What do I need to make this code
Rotating feed work on my index.htm or index.php work?

<?php
$insideitem = false;
$tag = "";
$title = "";
$description = "";
$link = "";
$locations = array('http://michaelthompson.org/news/goo-world.xml', 'http://forums.seochat.com/external.php', 'http://michaelthompson.org/news/goo-world.xml');
srand((float) microtime() * 10000000); // seed the random gen
$random_key = array_rand($locations);
function startElement($parser, $name, $attrs) {
global $insideitem, $tag, $title, $description, $link;
if ($insideitem) {
$tag = $name;
} elseif ($name == "ITEM") {
$insideitem = true;
}
}
function endElement($parser, $name) {
global $insideitem, $tag, $title, $description, $link;
if ($name == "ITEM") {
printf("<dt><b><a href='%s' target=new>%s</a></b></dt>",
trim($link),htmlspecialchars(trim($title)));
printf("<dt>%s</dt><br><br>",htmlspecialchars(trim($description)));
$title = "";
$description = "";
$link = "";
$insideitem = false;
}
}
function characterData($parser, $data) {
global $insideitem, $tag, $title, $description, $link;
if ($insideitem) {
switch ($tag) {
case "TITLE":
$title .= $data;
break;
case "DESCRIPTION":
$description .= $data;
break;
case "LINK":
$link .= $data;
break;
}
}
}
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
$fp = fopen($locations[$random_key], 'r')
or die("Error reading RSS data.");
while ($data = fread($fp, 4096))
xml_parse($xml_parser, $data, feof($fp))
or die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
fclose($fp);
xml_parser_free($xml_parser);
?>




Do I need a program installed on the directory it resides? My host allows my unlimited domains. I use Add on domain feature.

Thank youi!
st12

yfs1
Feb 2nd 2006, 9:45 am
You only need to have php enabled...There is no software involved.

Have you tried cut and pasting it? If so, what errors have you received?

ST12
Feb 2nd 2006, 9:48 am
Yfs1, I tried cut and paste and received the code itself on the index.htm page. Do I need to put the code in the index.htm file? Should I save it as .php?

Here is the test website:
www.quitsmokinghelp.be

Thank you!

I tried saving the index.htm as index.php still no luck. I spoke with my webhosting company they said php is enabled by default and it is curently enabled.

ST12
Feb 2nd 2006, 2:44 pm
Anybody knows how many things I am missing here with these RSS feeds:)?

Deano
Feb 2nd 2006, 3:07 pm
Do I need to put the code in the index.htm file? Should I save it as .php

Yes it's php code save as index.php, upload it, then remove your index.htm page from your server, so that there is no conflict.

ST12
Feb 2nd 2006, 3:10 pm
That's what I did saved it as .php, uploaded it, and removed the index.htm didn't work.:(

A strange animal probably resides in my webhosting company :(
I sent them an email .... now waiting.

Thank you Deano!

Deano
Feb 2nd 2006, 9:17 pm
Hi ST12

I pasted your code into one of my pages it worked fine.

Where are you placing the code. Try placing it in between the body text if you are not doing that already.

If you are then try a simple php hello world, to test your host as set you up for php correctly.

Deano

ST12
Feb 3rd 2006, 1:16 am
May be it is a web host issue. I am waiting for their reply.

Appreciate your help,
st12

ST12
Feb 3rd 2006, 3:09 pm
I got an email from Hostgator. They HAVE BLOCKED RSS. Reason - their servers got overloaded..

I am using less than 10% of my bandwidth. May be some scripts are run on their servers.
st12

crafty
Feb 3rd 2006, 4:35 pm
Hi
I have been using the code supplied by YSFI for some time now...it works great ..., however I was wondering if there was a way to limit the number of items that it displays as I thought with about 30 items showing, the pages may take longer to load than if it was limited to say 12.
Thanks
Tony

Deano
Feb 3rd 2006, 10:42 pm
I got an email from Hostgator. They HAVE BLOCKED RSS. Reason - their servers got overloaded..

I am using less than 10% of my bandwidth. May be some scripts are run on their servers.
st12

Tell them you are paying for a certain amount of bandwidth, it is up to you how you use it. If they won't let you use RSS then tell them you are moving at the end of your contract, as there are plenty of hosts out there who will accept it!

Deano

ST12
Feb 4th 2006, 9:08 am
This is what they say on their forum:

"...As of January 31, 2006 the following scripts have been banned from our servers:

http://RSStoBlog.com
http://RSSContentBuilder.com
http://RSSFeedReader.com
http://SubmitYourURL.info

If you find the need to use any of these scripts please reply to this thread and this thread only as we are using it to work with the developers of the software.

We are currently waiting to hear back from a representative so we can find a working solution that will not cause the servers to overload and go offline.
__________________
Regards,
Ben Gabler
Support Operations Manager,

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Visit Our Knowledgebase & Ticket System!
http://www.hostgator.com/help
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=







Do you guys normally just copy and paste the RSS script within the body of a file?
As far as I understand it that's all I need.

I let them know about the usage I have. Waitin for their reply.
Thank you again,
st12

AlanRenzi
Feb 4th 2006, 7:51 pm
ST12,

I too use HostGator. I think after reading your post I've figured out why some things haven't been working for me.

Thanks for the heads up.

Alan

ST12
Feb 4th 2006, 9:43 pm
Alan

Probably we need to protest this to the hostgator team. We live in 21st century. They have to improve their service or risk losing us.

I 've already sent them an email with my opinion.
Take care.
st12


May be it is time to look for another hosting company which allows unlimited domains. Let me know please if you come across one.

The Big Deal
Feb 4th 2006, 9:49 pm
Interesting, I use a lot of RSS and was thinking about using Hostgator for some new sites, I guess I will pass. Thanks for the info.

vic_msn
Feb 5th 2006, 1:34 am
Thanks for your informative post

jimKeough
Feb 5th 2006, 8:55 am
will it display images and work with yahoo media rss too?

smetten
Feb 7th 2006, 2:08 am
Hi I get alot of html code when using the rotating script. Can somebody help me with this. I saw this question was asked before but it wasn´t answerd.

Greetz

Smetten

obenix
Feb 7th 2006, 2:30 am
What codes are you getting?

yfs1
Feb 7th 2006, 2:36 am
Hi I get alot of html code when using the rotating script. Can somebody help me with this. I saw this question was asked before but it wasn´t answerd.

Greetz

Smetten
Make sure PHP is enabled on your server...Although as Obenix says a link would help

smetten
Feb 7th 2006, 2:44 am
It´s on my localhost, i'm just testing things out.
php is enabled because i copied the code in a php page wich loaded fine. It just shows html in the feed.

example of two articles of the feed:

Hamas says it expects to head new Palestinian govt
Asked whether a Hamas member would become the new prime minister, Hamas leader Ismail Haniyeh told Reuters in Cairo: "This is highly expected." But he said it was too soon to talk about names. <p><a href="http://feeds.feedburner.com/~a/reuters/worldNews?a=wrR5dm"><img src="http://feeds.feedburner.com/~a/reuters/worldNews?i=wrR5dm" border="0"></img></a></p><img src="http://feeds.feedburner.com/reuters/worldNews?g=12701"/>


Philippines close to peace deal with rebels
KUALA LUMPUR (Reuters) - Muslim rebels and the Philippine government are close to a deal on land claims, the key to ending a 40-year insurgency that has cost more than 120,000 lives, the facilitator of the talks said on Tuesday. <p><a href="http://feeds.feedburner.com/~a/reuters/worldNews?a=jBgsts"><img src="http://feeds.feedburner.com/~a/reuters/worldNews?i=jBgsts" border="0"></img></a></p><img src="http://feeds.feedburner.com/reuters/worldNews?g=12686"/>

ps. I just have this problem with your example feed of reuters. Probably because other feeds i tried it with don´t have images.

Another problem:
I want to change the font of the title and description, how do I insert the html code in the php script to do this?

Greetz

Smetten

poseidon
Feb 9th 2006, 11:43 pm
Thanks alot yfs1 sir :D :p it's working great..

and ya I too want to know what smetten is asking. How to customized it ?

ST12
Feb 10th 2006, 1:36 am
Smetten I got the same issue. Post here please if you ever solve it. Interestingly they are clickable and you can read the news, but seeing the codes is something that is good to be fixed.
Thank you
st12


Here is an example:

Ex-president Preval takes lead in Haitian election
PORT-AU-PRINCE, Haiti (Reuters) - Former President Rene Preval appeared headed for an outright victory in Haiti's first election since Jean-Bertrand Aristide was ousted two years ago, according to rivals and initial vote counts. <p><a href="http://feeds.feedburner.com/~a/reuters/worldNews?a=C7EpjB"><img src="http://feeds.feedburner.com/~a/reuters/worldNews?i=C7EpjB" border="0"></img></a></p><img src="http://feeds.feedburner.com/reuters/worldNews?g=12976"/>


You can check it at:
http://www.quitsmokinghelp.be/



Not to forget: Thank you YSF1!!! This is the first RSS I got working ..... a bit:)

Notting
Feb 14th 2006, 7:20 am
Sorry but I still don't understand how to do this. Could someone please explain what to do with the code. I want news stories from search phrase "nottingham" to appear on a page on my site.

Thanks for your help
Jamie

yfs1
Feb 14th 2006, 7:39 am
Sorry but I still don't understand how to do this. Could someone please explain what to do with the code. I want news stories from search phrase "nottingham" to appear on a page on my site.

Thanks for your help
Jamie
This code doesn't create the RSS it only displays it. You will first have to create a feed (or have someone create one) that does what you are asking.

I doubt one already exists.

You could always create a blog and post Nottingham news then use the RSS feed from it

Deano
Feb 14th 2006, 11:00 am
I want news stories from search phrase "nottingham" to appear on a page on my site.

try this feed

http://news.google.com/news?hl=en&ned=us&q=nottingham&ie=UTF-8&output=rss

Notting
Feb 15th 2006, 6:12 am
Hi,

Deano - I think this feed will work for me.

So how do I use this code to display stuff from that feed?

Thanks
jamie

Deano
Feb 15th 2006, 4:03 pm
In theory you should replace the line where it says
"http://michaelthompson.org/news/goo-world.xml"
with "YourRSSfeed"
Then put it into the body text,

Unfortunately i could not get it to work due to the "image" problem that people have mentioned with this feed.

Sorry, maybe someone more experienced than me will be able to help.

Dejavu
Feb 15th 2006, 4:45 pm
I havent read all 9 pages of this thread, but I'm gonna make a suggestion (not sure if it has been mentioned before)
While the original code yfs1 posted will work (and thanks for posted it btw), I think its better to use something like MagpieRSS (http://magpierss.sourceforge.net/)that caches the data..
Better for you since it can display the feeds even when the rss feed is down, and better for the site providing the feed, since you dont have to request it every time you display it. (saves a lot of bandwidth and server resources)

I have some example code on how to use it here:
http://www.articletrader.com/feeds/using-rss-feeds/

PinoyIto
Feb 16th 2006, 4:19 am
I have use this script since ysf1 start this thread but I just notice today that the For a Straight Feed script seem's not working for atom.xml (feeds from blogger.com)

Does anyone of you also encounter this problem or I am only the one? The scripts works very well to other feeds except blogs using the atom.xml

Crusader
Feb 19th 2006, 3:41 am
Anyone got an idea if this script could be modified in some way to perhaps take a random item(s) from the feed. Not necessarily in the order they occur in the feed.

vic_msn
Mar 4th 2006, 6:47 am
mods can you stick this post. its really usefullfor everyone

nemolist
Mar 7th 2006, 3:55 am
how many feeds i can have on one by using your script( i used first) PHP page?
i copy 1 st script and put on my web page, it was great,
but i was interesting to have few different feeds on the same page, and it did not work.

can i or can not have multiple feeds with this script?

thnks

pcdoc
Mar 7th 2006, 4:37 am
I work with others, mostly real estate agents and brokers, integrating RSS feeds into their web sites.

See http://www.1stpageseo.com/

Solicitors Mortgages
Mar 9th 2006, 12:14 pm
does someone want to summarise this post so it actually makes sense? is it for .php pages? .html pages? do you just paste the code onto an html page where you want the feed to appear? in the head, footer, body? does it need tweaking does it work? because it doesnt appear to on YFS1's site all i see are errors....

all I want to do is add a bloody feed, not my own feed ..I don't want to create one..i just want to insert BBC frikkin news headlines onto a page and have them change automatically every once in a while, that's all....where are the bloody tutorials on the internet?

man this has got me pi**ed !!!

Dejavu
Mar 9th 2006, 12:23 pm
It is for php pages.
But while this code might work, there are better ways that actually caches the feeds.

I have some info and code that you can just copy/paste to your site here:
http://www.articletrader.com/feeds/using-rss-feeds/

Solicitors Mortgages
Mar 9th 2006, 12:40 pm
It is for php pages.
But while this code might work, there are better ways that actually caches the feeds.

I have some info and code that you can just copy/paste to your site here:

and this will enable me to add the BBC healine feed to my html pages?

Dejavu
Mar 9th 2006, 12:49 pm
You will need php to display an rss feed.
You can setup your server to handle your html pages as php, then the code will work.
(And you can use the example code to display BBC headlines, just use the feed from the BBC instead of the feed from my site)

nemolist
Mar 11th 2006, 10:05 am
Hi,
for those 2 scripts, is it possible to change text size and font?

thanks

nemolist
Mar 11th 2006, 9:20 pm
hi,
anyone, is it possible to have more that one script, on a page,
i am talking about scripts in this thread.

thanks

dotcompals
Mar 13th 2006, 4:16 am
Showing html codes when i tried : Please help me on this.
http://www.newswallet.com/images/feed-display.jpg

ST12
Mar 14th 2006, 12:18 am
I would like to know too. I got the same issue and gave up on RSS for the moment. If somebody know how to get fix it, please tell us!:)
Thanks

ST12
Mar 16th 2006, 1:42 pm
No one seems to know the answer to this "mistery"!:)

browntwn
Mar 16th 2006, 3:37 pm
Whoohoo, I finally got it figured out. Thanks for all the tips.

I wish someone would have highlited the spaces in the code where you makes you personal adjustments. My skill could fit in a thimble, but I like to try and work this stuff out myself. It took me way too long to figure out where to paste my rss feed to get the dang thing to work.

Anyway, thanks to all for the tips.

ST12
Mar 17th 2006, 6:40 pm
Could you please share with us how did you get that code out of your pages?
Thank you!
st12

eddie0816
Mar 24th 2006, 2:00 am
First of all, I am so impressed about the amount of knowledge in here...hence the reason for my post.

If I wanted to paste the script that is in the first post of this thread onto one of my pages, where would I paste it? In between what tags? Does it have to show up in the <body> or <head> or anything?

Also, if I change the name of the file to .php I am assuming that it would work fine. Or, can I leave it as an .html file?

I appreciate any help I can get.

Thank You

yfs1
Mar 24th 2006, 2:06 am
It is just a snippet of php code and can be on any type of page, provided php is enabled (same as coop)

It should be in the body, where you want it (Not in the head)

eddie0816
Mar 24th 2006, 2:20 am
I can't type thank you quick enough. I haven't tried it yet, but I am sure with your help it will work.

Thank You

zach2k6
Mar 24th 2006, 2:39 am
Just tried it, Had to edit my Htaccess file for it to work on my html site.

How can I change the fonts and colours of the text?

eddie0816
Mar 24th 2006, 2:43 am
I also just tried it, but it didn't work. I could see everything from this part of the code...

%s", trim($link),htmlspecialchars(trim($title))); printf("
%s

all the way to the end of the code on the page itself.

Please, any help would be greatly appreciated.

yfs1
Mar 24th 2006, 2:49 am
I also just tried it, but it didn't work. I could see everything from this part of the code...

%s", trim($link),htmlspecialchars(trim($title))); printf("
%s

all the way to the end of the code on the page itself.

Please, any help would be greatly appreciated.

Have you tried a test piece of html to make sure php works (Like the previous poster said, you may have to add a line to your htacces)

eddie0816
Mar 24th 2006, 2:51 am
Here comes the newbie part. I have no idea what a test piece of code is.

However, I'd love to try one.

eddie0816
Mar 24th 2006, 2:52 am
I do have .php files on my site. Meaning some pages that end in .php. I don't
know if that means anything.

Rollo
Mar 24th 2006, 7:24 am
nice script yfs1, just wondering how would one go about display the links on a page instead of <a href> tags?

pcdoc
Mar 25th 2006, 6:44 am
You paste it where you want the output to be displayed on your page.

Click on my sig (1stpageseo), look at my portfolio to see how I implement RSS in my customers' sites.

greenworld
Apr 1st 2006, 9:20 pm
could this script be any good together with rss2blog?
sorry if it is a newbie question,
thanks

greenworld
Apr 12th 2006, 11:57 pm
Hello, I like to test this as well, it seems not too complicated but not working for me.

I have pasted the whole code into the body part of a new page ( php page made in dreamweaver), saved the page as rss-test.php,
I already have php page in mysite, so I think it should not be a problem, the only thing I did change was the rss feed,
uploaded the file to server,
load the page in ie browser, nothing is on the page, I did change the rss feed with new ones couple of times, but same result, nothing shows up , no error nothing,
anyone know what possibly could go wrong?

I did check some of the portfolio section of pcdoc site from the sig. I could not find the same script on those pages.

thanks.

sebastya
Apr 13th 2006, 12:06 am
what's the difference between rotating and straight feeds?

deregular
May 10th 2006, 8:53 am
wonder if anyone knows how to echo out the actual name of the blog that the feed comes from?

the script seems confused as there are two < title > tags in an rss feed.. one outside the < item > element (name of blog) and one inside each < item > element (the actual post)

Id love to be able to let people know exactly where the feed comes from!!

any help is much appreciated.

devin
May 10th 2006, 8:27 pm
what is i need to displya, say, 3 links only?

loyalmart
May 18th 2006, 12:29 am
good stuff.. will try this...

carmen
May 22nd 2006, 1:41 am
Has anyone found a way to modify the original code that takes in multiple rss feeds so that what it will do is take multiple input feeds, mix them up and show x number of listings randomly on a website. X would be a predefined number.

nufcfan
Jun 2nd 2006, 3:04 pm
i run a vb forum and want to add more rss feeds but i don t know where to add this code above how do i go about it ? plz help

billybrag
Jun 12th 2006, 7:21 am
How would i display say, the top storie from 5 different rss feeds?

thanks

Mike

nemolist
Jun 12th 2006, 10:01 am
in your php script. would be nice.

nervo
Jun 16th 2006, 8:38 am
Firstly, thanks to all of you people willing to share the knowledge!! :)

Now, does anyone have any idea why am I able to run "straight" feed script on my site but not the "rotating" one?:confused:

Thanks!
nervo

finaldestination
Jun 19th 2006, 5:16 am
how to make take feed from two sources?


i get this error

Cannot redeclare startelement()

what i did was changd the url of feed location and copy pasted the full code twice...

Emory
Jun 25th 2006, 12:46 pm
The random script is not working for me--no error message or anything.

I use LastRSS (http://lastrss.webdot.cz/) and it works ok, no random though :(

Jez
Jun 26th 2006, 8:36 am
I am still using yfs1's cool script - have been for about a year now I expect. Excellent.

I have one question. Is it possible, or would it be possible to have the script work a little like adsense does and produce on topic feeds for the page or pages in question? That would be pretty cool.

greenworld
Jun 27th 2006, 12:20 am
thank you for sharing.

what the rotating feed means?
does it rotate feed?

I could only add one feed though.

today I did try it again after previous attempt, and got it to work,
I assume this script can only be used with one feed, I tried it with 2 feeds, did not work.

anyone using it with more than one feed?


thanks

nervo
Jun 30th 2006, 9:59 am
That's the same problem I have... I can't make that rotating feed script to work... ;(

WebFreedom
Jul 12th 2006, 7:03 pm
I am still using yfs1's cool script - have been for about a year now I expect. Excellent.

I have one question. Is it possible, or would it be possible to have the script work a little like adsense does and produce on topic feeds for the page or pages in question? That would be pretty cool.

Hi Jez,

I'm not sure if this is what you're looking for, but Allfeeds.com (http://publisher.allfeeds.com) has an XML Feeds program that can serve on-topic advertiser feeds to your web pages. It's not exactly the same as an rss news feed, but I thought it may be something of interest to you. I've had good results with their programs as an affiliate publisher.

HTH,
Sam

rezx
Jul 14th 2006, 5:09 am
Recently my yahoo rss feeds could not fetch the pictures and when i click on it it goes to a 404 page. :S

michaelwalker
Jul 24th 2006, 3:38 am
Dear readers,

I am trying to use the "straight" version of this script. It works fine with a single RSS feed however when i try to add multiple feeds i get this error:


Fatal error: Cannot redeclare startelement() (previously declared in /home/www/crkdeign/rss.php:42) in /home/www/crkdeign/rss.php on line 98

You can view my site @ http://server11.web-mania.com/users/crkdeign/rss.php
Thanks in advance.
Michael

yfs1
Jul 24th 2006, 3:40 am
You can only use one feed with the Straight code...You need to go with the rotating if you want multiple.

michaelwalker
Jul 24th 2006, 3:43 am
Will the rotating code allow me to display two different feeds at the same time? In different parts of the page?

yfs1
Jul 24th 2006, 3:46 am
Will the rotating code allow me to display two different feeds at the same time? In different parts of the page?

No, both sets of code were originally for only providing one feed

michaelwalker
Jul 24th 2006, 3:48 am
hmm do you know of any scripts that will allow me to provide two feeds? Or could i include the feeds separetly using php include function?

yfs1
Jul 25th 2006, 8:17 am
hmm do you know of any scripts that will allow me to provide two feeds? Or could i include the feeds separetly using php include function?

Yes, CaRP is probably the best one out there. I created the code in this thread nearly 2 years ago when there were very few options (or the options that were out there had complex explanations)

I am using CaRP here:
http://www.hapahapa.com/latest-news.htm

It is extremly adaptable and can be very easily changed as far as layout.

If you want to try it and post any questions here. To be honest I'm more comfortable helping people with that code then the ones in this thread as its been years at this point

kelp
Jul 29th 2006, 11:05 pm
I'm having trouble finding the config options to do the following in CaRP:
Remove the <br />'s after every line
Remove where the feed is from and the description of the feed
Making the link target in _blank and adding rel="nofollow" to the link

Here's what I have so far:
CarpConf('maxitems',10);
CarpConf('iorder','link');
CarpConf('bi',' <li>');
CarpConf('ai','</li>');
CarpConf('poweredby','');

Basically I just need it to show up like this:
<li><a href="" target="_blank" rel="nofollow">Hi</a></li>

Jen-
Jul 31st 2006, 4:57 pm
Hello, I'm a bit late on this thread, hope some of you are still around.

I am having trouble getting ssi include command to work on my main page. It works on my other pages just fine any suggestions?

Also, anyone know how to make magpie include rss images? I have the news feeds working just fine. Thanks Jen-

pcdoc
Aug 1st 2006, 3:00 am
I am having trouble getting ssi include command to work on my main page.

a URL would help ;-)

ajscottsr
Aug 20th 2006, 5:55 pm
I made modifications to the ORIGINAL script posted at the beginning of this page to use echo instead of printf and to use cURL instead of fopen for those hosts that don't allow fopen to remote servers such as dreamhost.

I inserted the google news feed URL and it works great:

http://www.outblogger.com/demo/dp_rss.php

Here ya go:

<?php
$insideitem = false;
$tag = "";
$title = "";
$description = "";
$link = "";
$locations = array('http://news.google.com/?ned=us&topic=s&output=rss', 'http://news.google.com/?ned=us&topic=s&output=rss', 'http://news.google.com/?ned=us&topic=s&output=rss');
srand((float) microtime() * 10000000); // seed the random gen
$random_key = array_rand($locations);
function startElement($parser, $name, $attrs) {
global $insideitem, $tag, $title, $description, $link;
if ($insideitem) {
$tag = $name;
} elseif ($name == "ITEM") {
$insideitem = true;
}
}
function endElement($parser, $name) {
global $insideitem, $tag, $title, $description, $link;
if ($name == "ITEM") {
echo "<dt><b><a href='" . trim($link) . "' target='new'>" . trim($title) . "</a></b></dt>\n";
echo "<dt>" . trim($description) . "</dt><br><br>\n";
//printf("<dt><b><a href='%s' target=new>%s</a></b></dt>",trim($link),htmlspecialchars(trim($title)));
//printf("<dt>%s</dt><br><br>",htmlspecialchars(trim($description)));
$title = "";
$description = "";
$link = "";
$insideitem = false;
}
}
function characterData($parser, $data) {
global $insideitem, $tag, $title, $description, $link;
if ($insideitem) {
switch ($tag) {
case "TITLE":
$title .= $data;
break;
case "DESCRIPTION":
$description .= $data;
break;
case "LINK":
$link .= $data;
break;
}
}
}
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $locations[$random_key]);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
curl_close($ch);

//$fp = fopen($locations[$random_key], 'r') or die("Error reading RSS data.");
// while ($data = fread($fp, 4096))
xml_parse($xml_parser, $data) or die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser)));
//fclose($fp);
xml_parser_free($xml_parser);
?>

Hope you find this useful, thanks!

bizzy
Sep 18th 2006, 6:06 pm
Thanks to yfs1 and ajscottsr for posting and modifying this script. It is working well!

Oppenheimer Group
Sep 25th 2006, 6:14 pm
Great code thanks!

bentong
Sep 25th 2006, 7:01 pm
Basically I just need it to show up like this:
<li><a href="" target="_blank" rel="nofollow">Hi</a></li>

CarpConf('biurl','<a target="_blank" rel="nofollow" href="');
CarpConf('aiurl','">');
CarpConf('ailink','</a>');

dont know about the others.

PinoyIto
Oct 9th 2006, 5:23 am
seems that the script is not working at blogger search result rss feed any more... what the adjustment should we do so that it work again.

Yellowberry.org
Nov 12th 2006, 7:58 pm
Great idea! However i have Hostgator so i will try the maggie script first. I will show you a demo as soon as i get it up.

david boon
Nov 13th 2006, 3:52 am
Great work ...... i appreciate you for your hard work...

at the same time there is a problem as well.......Let me explain...

Generally when we click on the dynamic content we expect a new window to get opened .....but that is nt happening here...instead that link in getting opened in the same window(which i dont like coz i dont want my visitors to get out of my site completly)...

Is there any tweak or additional code to be inserted so that all the links will get opened in a seperate window??

regards,
boon

Yellowberry.org
Nov 13th 2006, 6:54 am
I am using

http://www.articletrader.com/feeds/using-rss-feeds/

I wanted it on my right side where it said thai news now

www.bangkokflowershop.com

But i could not change the layout that much is it possible. Besides that it working very good.

fadetoblack
Nov 16th 2006, 9:29 pm
can i incorprate the abve code in a html file or should it be a php file with a link pointing to it..

Absolute
Nov 22nd 2006, 3:39 pm
how could I make this work on a blog?

pipes
Dec 27th 2006, 6:35 am
Thanks for all of the info in this thread, its helped me to understand RSS a lot better.

aj22
Jan 3rd 2007, 9:45 am
Anyone know how to trim the description to a certain amount of characters? Thanks!

dalani
Jan 3rd 2007, 9:44 pm
it's a great program i'd like to use on my site as well.
can i incorprate the abve code in a html file or should it be a php file with a link pointing to it..

I am wondering about that too..I wish someone would answer that question..

eg. a simple php hello world [hello.php] :
<html>
<body>

<?php
echo "Hello World";
?>

</body>
</html>

doesn't give me an 'hello world' when pasted anywhere in my webpage.

I tried an include

<?php include("hello.php"); ?>

didn't work either.
Sorry for being off topic and such a newbie but any help with that would allow use of Ysf1's great Rss display code.
EDIT: Yes, my webserver is PHP enabled

selfstyledexpert
Feb 21st 2007, 5:59 pm
this post might help some of you

http://forums.digitalpoint.com/showpost.php?p=167920&postcount=95