FeedForAll Forum Index  
 Home  •  FAQ  •   Search   •  Register   •  Profile   •  Log in
 rss2html.php usage examples View next topic
View previous topic
Post new topicReply to topic
Author Message
Tech Support



Joined: 27 Aug 2004
Posts: 2783

PostPosted: Sat May 07, 2005 4:29 pm Reply with quoteBack to top

Simple examples of how to use FeedForAll's fre rss2html.php script:

Contents

Example 1: Running rss2html.php from our web server, using one of our sample templates, to generate a webpage from an RSS feed

Example 2: Running rss2html.php from your web server, using a custom template, to generate a webpage from an RSS feed

Example 3: Using a server side inclusion to insert a RSS feed's contents into an existing webpage

Example 4: Using server side inclusions to insert multiple RSS feeds from other websites, into an existing webpage


Example 1: Running rss2html.php from our web server, using one of our sample templates, to generate a webpage from an RSS feed

Requirements:
None

Steps:
1. Create the following a link on an existing webpage:

http://www.rss2html.com/public/rss2html.php?TEMPLATE=http://www.rss2html.com/public/basic-webpage.html&XMLFILE=(url to your rss feed)

The above link should be all on a single line (no line breaks), and the '(' and ')' characters should not be included. Here the above link, using one of our feeds:

http://www.rss2html.com/public/rss2html.php?TEMPLATE=http://www.rss2html.com/public/basic-webpage.html&XMLFILE=http://www.feedforall.com/blog-feed.xml


Example 2: Running rss2html.php from your web server, using a custom template, to generate a webpage from an RSS feed

Requirements:
PHP 4.x running on your webserver

Steps:
1. Download our free rss2html.php script from: http://www.feedforall.com/download/rss2html.zip

2. Extract the files and put them on your webserver (in a folder that can be accessed from a browser)

3. Edit the existing sample template, or create a new one of your own.

4. Create the following link on an existing webpage:

http://(url to rss2html.php on your web server)?TEMPLATE=(url to your custom template)&XMLFILE=(url to your RSS feed)

The above link should be all on a single line (no line breaks), and the '(' and ')' characters should not be included. Here the above link, using a fancier template file and one of our feeds:

http://www.feedforall.com/rss2html.php?TEMPLATE=http://www.feedforall.com/fancy-sample.html&XMLFILE=http://www.feedforall.com/blog-feed.xml


Example 3: Using a server side inclusion to insert a RSS feed's contents into an existing webpage

Requirements:
PHP 4.x running on your webserver
Server Side Inclusions support on your webserver

Steps:
1. Download our free rss2html.php script from: http://www.feedforall.com/download/rss2html.zip

2. Extract the files and put them on your webserver (in the same folder that your new webpage, and your RSS feed will be in)

3. Create a template for rss2html.php, that will result in the 'guts' of a table.
    a. Example:
    Code:
    ~~~BeginItemsRecord~~~
    <TR>
        <TD>
            ~~~ItemPubShortDate~~~ ~~~ItemPubShortTime~~~
        </TD>
    </TR>
    <TR>
        <TD>
            <B><A href="~~~ItemLink~~~">~~~ItemTitle~~~</A></B>
        </TD>
    </TR>
    <TR>
        <TD>
            ~~~ItemDescription~~~
            <BR>
            <BR>
        </TD>
    </TR>
    ~~~EndItemsRecord~~~

    b. Save your template into the same folder as the rss2html.php script and your RSS feed file


4. Create a new webpage that you want your RSS feed displayed in.
    a. In the new webpage, create a new table, and put only a server side include command in the table.
    b. Example
    Code:
    <TABLE>
        <!--#INCLUDE VIRTUAL="rss2html.php?TEMPLATE=(name the template you created in step 3)&XMLFILE=(name of your RSS feed file)" -->
    </TABLE>

    c. Save your new webpage in the same folder as the rss2html.php script and your RSS feed file
    d. Most servers will require you to save the new webpage with .shtml as the extension (instead of .htm or .html), so the server will know to look for SSI commands in the webpage.


Example 4: Using server side inclusions to insert multiple RSS feeds from other websites, into an existing webpage

Requirements:
PHP 4.x running on your webserver
Server Side Inclusions support on your webserver

Steps:
1. Download our free rss2html.php script from: http://www.feedforall.com/download/rss2html.zip

2. Extract the files and put them on your webserver (in the same folder that your new webpage, and your template will be in)

3. Create a template for rss2html.php, that will result in the 'guts' of a table.
a. Example:
Code:
~~~BeginItemsRecord~~~
<TR>
    <TD>
        ~~~ItemPubShortDate~~~ ~~~ItemPubShortTime~~~
    </TD>
</TR>
<TR>
    <TD>
        <B><A href="~~~ItemLink~~~">~~~ItemTitle~~~</A></B>
    </TD>
</TR>
<TR>
    <TD>
        ~~~ItemDescription~~~
        <BR>
        <BR>
    </TD>
</TR>
~~~EndItemsRecord~~~

b. Save your template into the same folder as the rss2html.php script.

4. Create a new webpage that you want your RSS feed displayed in.
a. In the new webpage, create a new table, and put one or more server side include commands in the table.
b. Example
Code:
<TABLE>
    <!--#INCLUDE VIRTUAL="rss2html.php?TEMPLATE=(name the template you created in step 3)&XMLFILE=(URL for the first RSS feed file to display)&MAXITEMS=(number of items to display from this feed)" -->
    <!--#INCLUDE VIRTUAL="rss2html.php?TEMPLATE=(name the template you created in step 3)&XMLFILE=(URL for the second RSS feed file to display)&MAXITEMS=(number of items to display from this feed)" -->
    <!--#INCLUDE VIRTUAL="rss2html.php?TEMPLATE=(name the template you created in step 3)&XMLFILE=(URL for the third RSS feed file to display)&MAXITEMS=(number of items to display from this feed)" -->
</TABLE>

c. Save your new webpage in the same folder as the rss2html.php script and your template.
d. Most servers will require you to name the new webpage with .shtml as the extension (instead of .htm or .html), so the server will know to look for SSI commands in the webpage.

_________________
Create RSS Feeds
Audio Recording and Editing
View user's profile
MacSupport



Joined: 24 Feb 2005
Posts: 2805

PostPosted: Sun Jul 31, 2005 10:42 am Reply with quoteBack to top

someone wrote:
Does this script can use this code to include from php files ? :
Code:
include ("./rss2html.php?TEMPLATE=xxx&XMLFILE=xxx&MAXITEMS=xxx");


If not , is there anyway to do it ?

I'm newbie php .
Plz help me !


If you want to do an include with parameters you would need to do
Code:
include ("http://your.domain.com/rss2html.php?TEMPLATE=xxx&XMLFILE=xxx&MAXITEMS=xxx");
However, since most hosting companies are turning of "allow_fopen_url", this won't work. The safest option is to use Server Side Includes and not a PHP include.

Jim
View user's profileVisit poster's website
MacSupport



Joined: 24 Feb 2005
Posts: 2805

PostPosted: Thu Dec 22, 2005 5:27 pm Reply with quoteBack to top

snimmons wrote:
I'm trying the SSI with example 3, but all I get is a code dump of the script in the html, not the coverted RSS. Any ideas what could be wrong?


First, are you using Apache as your web server?

Are server side includes enabled for the file extension of your page?

Jim
View user's profileVisit poster's website
MacSupport



Joined: 24 Feb 2005
Posts: 2805

PostPosted: Thu Dec 22, 2005 6:01 pm Reply with quoteBack to top

snimmons wrote:
Not sure of the webserver type. I'm using Windows hosting with GoDaddy - I will raise the question with them.



If you are using windows hostig then it is most likely running on IIS, and Apache style SSI won't work. PHP is problably your best bet.

snimmons wrote:
I've tried using a php include on a dummy page and that works fine, I also see the fopen is allowed on the php support (on my godaddy account).


I get a blank page with your URL too, but when I chage the to use a different server I do get results. Did you edit the script to use fopen? If not change so it does.

snimmons wrote:
I'm trying to hit the url direct using this: I get an empty (well formed page), but with no links


The no links is because your template doesn't have links in it.

snimmons wrote:
http://www.luton-lambeg.org/test/rss2html.php?XMLFILE=http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/northern_ireland/rss.xml&TEMPLATE=http://www.luton-lambeg.org/test/sample-template.html&MAXITEMS=10

I also tried a php page http://www.luton-lambeg.org/test/testpage.php using an include as below (have tried various variants with relative and absolute paths to the script and template.

<?
include("rss2html.php?XMLFILE=http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/northern_ireland/rss.xml&TEMPLATE=sample-template.html&MAXITEMS=10")
?>

Is is ok to use php include given fopen is supported? Any idea then why I'd get a blank page? I tried pointing at other remote RSS feeds and other remote templates and simply calling rss2html from my server, but same result.

Ideas most welcome :-)

thx...
View user's profileVisit poster's website
MacSupport



Joined: 24 Feb 2005
Posts: 2805

PostPosted: Thu Dec 22, 2005 8:28 pm Reply with quoteBack to top

snimmons wrote:
Have reverted to the sample template in the download zip file, which now includes links. Have set $useFopenURL = 1; in the php script. These are published on the web server, but I still get blank page on a direct URL hit, and obviously therefore no html where I try to insert the RSS feed.

Anything I can check / try?

thx...


Not sure, but I tried your URL using the rss2html.com 's public copy and it worked just fine.

http://www.rss2html.com/public/rss2html.php?XMLFILE=http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/northern_ireland/rss.xml&TEMPLATE=http://www.luton-lambeg.org/test/sample-template.html&MAXITEMS=10

I am not sure what else to suggest since your host is using windows and not Apache and Unix.

Jim
View user's profileVisit poster's website
MacSupport



Joined: 24 Feb 2005
Posts: 2805

PostPosted: Fri Dec 23, 2005 2:13 pm Reply with quoteBack to top

snimmons wrote:
Thanks for the assistance. I tried a couple of other similar php scripts for the same purpose and they all returned nothing as well. I tried CARP which indicated to me that fopen and fsockopen were not working correctly. I see on the GoDaddy hosting plans some differences in the php support on Windows and Linux. I also gave a couple of .asp solutions a whirl, but no joy. Rather than slog along, I've decided to move the hosting plan onto Linux, which I think has a better chance of success. That takes approx 72 hours - so enough time to eat lots of Xmas food and then come back to it :-)

A couple of things might be useful to add:
1. Something like CARP has to check PHP support on the target server to indicate if your php script will (or should work)?
2. A debug version of the script, with some additional echo statements and a $debug={0,1} variable to control operation. I wrote some diagnostics in to see where the script tanked, perhaps one to consider for tracing issues?

Anyway I give it a try in a day or 2 on Linux and fingers crossed :-)


You are not the first person to mention on this forum that they needed to switch from GoDaddy Windoze to Linux.

The newest versions of the script have an option "?buildURL" that helps to make sure the URLs that are passed to it are properly encoded. The is also useful for general debugging to make sure you are able to read the feed.

Jim
View user's profileVisit poster's website
bart



Joined: 02 Feb 2006
Posts: 3

PostPosted: Thu Feb 02, 2006 5:10 pm Reply with quoteBack to top

Jim,

Instead of have mulitple data feeds on on epage is there a way to rotate through a list of data feeds? Say through a array command?

I am fairly new to php and coding in general, so even a nudge in the right direction would be a great help.

Cheers,

_________________
Bart
View user's profile
MacSupport



Joined: 24 Feb 2005
Posts: 2805

PostPosted: Thu Feb 02, 2006 5:55 pm Reply with quoteBack to top

bart wrote:
Jim,

Instead of have mulitple data feeds on on epage is there a way to rotate through a list of data feeds? Say through a array command?

I am fairly new to php and coding in general, so even a nudge in the right direction would be a great help.

Cheers,


Anything is possible. I will give you 2 different options.

1. The easiest code wise, but requires editing rss2html.php which may make upgrades harder. Change the line

Code:
$XMLfilename = "sample.xml";


to

Code:

$XMLFiles[] = "http://www.somesite.com/feed1.xml";
$XMLFiles[] .= "http://www.anotersite.com/feed2.xml";
$XMLFiles[] .= "http://www.differentsite.com/feed3.xml";

srand ((double) microtime( )*1000000);
$random = rand(1,count($XMLFiles));

$XMLfilename = $XMLFiles[$random];



2. Is by modifying the call to rss2html.php in your .html page. This is probably the most flexable. But the server has to be configured to parse PHP in .html files. Most are, if not a single line can be added to the .htaccess file.

Code:


<?php

$path[] = "http://www.yourserver.com/rss2html.php?XMLFILE=http://www.somesite.com/feed1.xml";
$path[] .= "http://www.yourserver.com/rss2html.php?XMLFILE=http://www.anotersite.com/feed2.xml";
$path[] .= "http://www.yourserver.com/rss2html.php?XMLFILE=http://www.differentsite.com/feed3.xml";

srand ((double) microtime( )*1000000);
$random = rand(1,count($path));

include($path[$random]);

?>


Jim
View user's profileVisit poster's website
bart



Joined: 02 Feb 2006
Posts: 3

PostPosted: Thu Feb 02, 2006 6:51 pm Reply with quoteBack to top

Jim, you rock tanks a lot for your sweet code snippet.

Now I am not sure why but only two of the three feeds are showing up... all three feeds work. Here is my code:

<td><?php
$path[] .= "http://www.xylitol-gum.info/rss2html.php?XMLFILE=http://www.archivex-ht.com/articles/rss/Foods/97&TEMPLATE=http://www.xylitol-gum.info/sample-template.html&MAXITEMS=5";
$path[] .= "http://www.xylitol-gum.info/rss2html.php?XMLFILE=http://www.activearticles.com/rss/Health/4&TEMPLATE=http://www.xylitol-gum.info/sample-template.html&MAXITEMS=5";
$path[] .= "http://www.xylitol-gum.info/rss2html.php?XMLFILE=http://www.101articles.com/rss/Food/96&TEMPLATE=http://www.xylitol-gum.info/sample-template.html&MAXITEMS=5";
srand ((double) microtime( )*1000000);
$random = rand(1,count($path));
include($path[$random]); ?></td>

now I do get an error but I do not think it pertains to the situation, but here it is (my site uses php code to make html on the fly from my database, my freind let me play with the code for fun):

Warning: (null)(): Failed opening '' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/xylitol6/public_html/keyword.php(276) : eval()'d code on line 7

what do think is wrong?

_________________
Bart
View user's profile
MacSupport



Joined: 24 Feb 2005
Posts: 2805

PostPosted: Thu Feb 02, 2006 7:26 pm Reply with quoteBack to top

bart wrote:
Jim, you rock tanks a lot for your sweet code snippet.

Now I am not sure why but only two of the three feeds are showing up... all three feeds work. Here is my code:

<td><?php
$path[] .= "http://www.xylitol-gum.info/rss2html.php?XMLFILE=http://www.archivex-ht.com/articles/rss/Foods/97&TEMPLATE=http://www.xylitol-gum.info/sample-template.html&MAXITEMS=5";
$path[] .= "http://www.xylitol-gum.info/rss2html.php?XMLFILE=http://www.activearticles.com/rss/Health/4&TEMPLATE=http://www.xylitol-gum.info/sample-template.html&MAXITEMS=5";
$path[] .= "http://www.xylitol-gum.info/rss2html.php?XMLFILE=http://www.101articles.com/rss/Food/96&TEMPLATE=http://www.xylitol-gum.info/sample-template.html&MAXITEMS=5";
srand ((double) microtime( )*1000000);
$random = rand(1,count($path));
include($path[$random]); ?></td>

now I do get an error but I do not think it pertains to the situation, but here it is (my site uses php code to make html on the fly from my database, my freind let me play with the code for fun):

Warning: (null)(): Failed opening '' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/xylitol6/public_html/keyword.php(276) : eval()'d code on line 7

what do think is wrong?


That would be bad time 2. One for typing code in to the web without testing. And two for a stupid mistake.

Change
Code:
$random = rand(1,count($path));
to
Code:
$random = rand(1,count($path))-1;
and you should have all three and no more errors.

Jim
View user's profileVisit poster's website
bart



Joined: 02 Feb 2006
Posts: 3

PostPosted: Fri Feb 03, 2006 11:27 am Reply with quoteBack to top

Jim,

Your the RSS/PHP master!! It works... I am now pulling news from google, yahoo, and msn. All thanks to you my PHP guru forum friend. You saved me a lot of time.

And that sweet build link command is brilliant! It even changes the illegal characters from an RSS feed. WOW! Talk about ease of just copy & paste.

I am very pleased with the powerful FREE RSS2HTML script.

Tank you very much!

Cheers,

_________________
Bart
View user's profile
MacSupport



Joined: 24 Feb 2005
Posts: 2805

PostPosted: Fri Feb 03, 2006 11:32 am Reply with quoteBack to top

bart wrote:
Jim,

Your the RSS/PHP master!! It works... I am now pulling news from google, yahoo, and msn. All thanks to you my PHP guru forum friend. You saved me a lot of time.

And that sweet build link command is brilliant! It even changes the illegal characters from an RSS feed. WOW! Talk about ease of just copy & paste.

I am very pleased with the powerful FREE RSS2HTML script.

Tank you very much!

Cheers,


Thanks.
View user's profileVisit poster's website
scottparat



Joined: 01 Mar 2006
Posts: 9

PostPosted: Wed Mar 01, 2006 11:19 pm Reply with quoteBack to top

Hi Jim,

Man, you're doing an awesome job supporting a free script. I can't believe the quality of info you've been kindly handing out. You're definitely one step above the rest!

This script it awesome, now I feel like I need to buy something...any suggestions :)

I installed it and got it running without much problem, I'm pulling in some clickbank feeds on this page, about a 3/4 way down the page. http://www.spgraphic.com/jimedwards.htm

I feel a little guilty asking or suggesting this. In a couple of the above posts you demonstrate on how to pull in multiple feeds and then how to randomly display one of those scripts.

Would it be very difficult to do the following:

  • use more than one rss feed, maybe 3,4,5 or 6...
  • then randomly display a specific number of items that would be randomly chosen from the defined feeds
  • in other words, let's say I wanted 6 items to be chosen from 5 defined rss feeds

I'd like to be able to do something like that, but I realize I have no right to ask you to come up with it....just a thought.

Thanks again,

Scott

_________________
Internet Marketing Tools and Tips
View user's profile
MacSupport



Joined: 24 Feb 2005
Posts: 2805

PostPosted: Thu Mar 02, 2006 6:10 am Reply with quoteBack to top

scottparat wrote:
Hi Jim,

Man, you're doing an awesome job supporting a free script. I can't believe the quality of info you've been kindly handing out. You're definitely one step above the rest!

This script it awesome, now I feel like I need to buy something...any suggestions :)


I will email you the specs on a nice BWM 3 series....

Actually you can purchase this script and several others, including a caching module so the remote XML file won't be fetched very time. This can be big speed up.

scottparat wrote:
I installed it and got it running without much problem, I'm pulling in some clickbank feeds on this page, about a 3/4 way down the page. http://www.spgraphic.com/jimedwards.htm

I feel a little guilty asking or suggesting this. In a couple of the above posts you demonstrate on how to pull in multiple feeds and then how to randomly display one of those scripts.

Would it be very difficult to do the following:

  • use more than one rss feed, maybe 3,4,5 or 6...
  • then randomly display a specific number of items that would be randomly chosen from the defined feeds
  • in other words, let's say I wanted 6 items to be chosen from 5 defined rss feeds

I'd like to be able to do something like that, but I realize I have no right to ask you to come up with it....just a thought.

Thanks again,

Scott


As long as you don't want the items from each feed mixed, then it is easy. Just use include the rss2html.php script multiple times, once for each feed.

Jim
View user's profileVisit poster's website
taro



Joined: 19 Feb 2006
Posts: 5

PostPosted: Sat Mar 04, 2006 8:42 pm Reply with quoteBack to top

I am doing example3 + multi rss feed.
only the problem that i have been having is one of the feed is in UTF-8, and others are in Shift-JIS. Is there a way to display both of them at the same time?

thanks
View user's profile
Display posts from previous:      
Post new topicReply to topic


 Jump to:   



View next topic
View previous topic


Powered by phpBB © 2001, 2002 phpBB Group :: FI Theme