2RSS.com :: RSS feeds, RSS directory, RSS articles, RSS syndication, XML, RDF, news ... Directory My RSS 2RSS Reader Software Articles Contact Blog Forum
2RSS.com :: RSS feeds, RSS directory, RSS software, RSS scripts, RSS articles, RSS syndication, XML, RDF, news and more.


RSSlib

{v1.04}

This library allows you to add RSS content to your site, for free.Your site will look more professional with fresh content updated daily. See our online demo.

How it works?
You can find many RSS feeds on the Internet or browsing our directory. All you need is RSS file URL. Then you can install RSSlib scripts and customize them to add content directly to your web pages. These scripts are made with PHP & ASP*see note. You can use a separate <frame>, <iframe> or <div> to display RSS to your page. Or you can display them using JavaScript anywhere in your page.

Features
RSSlib functions allows you to control many parameters. Resulting HTML content is fully customizable using CSS. You can change font, colors and many more. Also, you can choose to use cached RSS feeds or every call will request a fresh RSS content. Then, you can set maximum items and maximum length for descriptions (longer descriptions could be truncated). Finally, you can set-up target for displaying documents (current or new browser window, a frame or anything else).

Installation

  • download RSSlib-php.zip or RSSlib-asp.zip and unzip all files
  • change first three lines in rsslib.php or rsslib.asp if you want to use cached pages. If the RSS content is not cached leave it as is. Also, you can customize rsslib.css file.
  • copy the files on your site
  • use rss2html.php or rss2js.php files for PHP or rss2html.asp or rss2js.asp for ASP in your HTML pages.

Technical details
RSSlib consists in a few files with .php or .asp extension. They are:

  • rsslib.php or rsslib.asp - core RSSlib functions: getrss(), rss2html(), rss2js(). This file is included in rss2html.php ( /.asp) & rss2js.php ( /.asp );
  • rss2html.php ( /.asp) - used to display any RSS feed in HTML format. You can use this file in <frame>, <iframe> tags or open it directly in browser (with proper parameters);
  • rss2js.php ( /.asp) - create JavaScript content which can be used in <script> tag. Or you can insert this content anywhere in your page using JavaScript (returns all content as document.write() calls);
  • rsslib.css - using it you can customize content appearance. See below all CSS styles.

To use these script files you should install them on your web site, locally. Then you can create links to these pages.

Also, RSSlib allows you to use cached RSS feeds for speed or traffic reasons. Instead of loading every time RSS content from original locations you can use a local copy. Read more here.

Function parameters
Rss2html() & rss2js() functions could have a few parameters passed thru query string (URL) to rss2html.php ( /.asp) and rss2js.php ( /.asp) pages. These are:

  • rss_url - contains URL to RSS feed, URL encoded (the only param mandatory)
  • rss_items - maximum number of items in RSS feed. If zero (0) or missing all items are returned.
  • rss_chars - if specified, description text will be truncated. If zero or missing all description is returned.
  • rss_css - CSS style prefix name used in rsslib.css file. Default is "rsslib". You can use it when a single CSS file is used for your page and RSS feed, to avoid conflicts.
  • rss_target - specify target frame or window where links are opened. Could be "_blank" ( = new window), "_top" ( = same window) or anything else. Default is "_blank".

For instance, after you install these files locally you can use something like these:

... <a href="rss2html.php?rss_url=...(RSS_feed_URL)...&rss_target=_blank">RSS feed name</a> ...
... <iframe width="200" height="300" src="rss2html.php?rss_url=...(RSS_feed_URL)...&rss_items=3"></iframe> ...
... <script language="JavaScript" src="rss2js.php?rss_url=...(RSS_feed_URL)...&rss_chars=100&rss_target=_top"></script> ...

For search engine friendly pages you can use server side includes. For PHP you can try:

<?php
include 'http://(your website location)/rss2html.php?rss_url=(...RSS_feed_URL..)&rss_items=10&rss_chars=100';
?>

New: For ASP you can use include with hardcoded parameters (ASP doesn't accept parameters with include files):

<!--#INCLUDE FILE = "rss2html.asp"-->

And rss2html.asp:

<!--#include file="rsslib.asp"-->
<%
' RSSlib @ 2RSS.com :: RSS directory, RSS scripts, RSS articles, RSS software.
' This scripts are distributed for free and are provided "AS IS" for PHP & ASP.
' For details read docs.htm or see our site.
' Copyright: www.2RSS.com

response.write "<link rel='stylesheet' href='rsslib.css' type='text/css'>" & vbcrlf
url="http://www.domain.com/rss_feed_url_hardcoded"
m=0
ch=0
t="_blank"
css="rsslib"
call rss2html(url,m,ch,t,css)
%>

The same technique is working with HTML files with server side include (SSI).
With this method you can create server-side HTML content from XML feeds in a way that is crawled by search engines. JavaScript solutions are not search-engine friendly (links just ignored by search engines).

CSS
All items from RSS feed are controlled by rsslib.css file. By default, all styles have rsslib prefix. You can change this prefix in rsslib.css file and all calls to rss2html() or rss2js() functions using rss_css parameter (as described above). Every information displayed by RSSlib uses a custom style. You can change them in rsslib.css file. Also you can include this file in other CSS files using @import. All styles are:

  • .rsslibchannel - used for channel description
  • .rsslibitem - used for each item title
  • .rsslibdesc - used for each item description
  • .rsslibeditor - editor of the channel
  • .rsslibdate - published date of the channel
  • .rsslibcopyright - copyright information

You can change directly any aspect of these styles.

Cache
RSSlib can use cached (for speed or traffic issues) or non-cached RSS feeds (default is cached). Doing this, a local copy of RSS feed is used instead of using RSS feed from its original location every time when functions are called. You can specify how long a cache is valid and where to keep this cache. Don't forget to create a folder where cached files are kept (default is "tmp" in current folder).
To enable/disable it you have to edit rsslib.php ( /.asp) file. At the beginning there are 3 parameters which controls caching:

  • use_cache - could be true or false. Default is true.
  • cache_folder - Default "tmp". You can use any other folder (you can change it for security reasons). You may need to change rights for this folder to allow file writing (CHMOD 777 or thru your FTP client for Linux / Unix)
  • cache_valid - Default is 60. Expressed in minutes. You can specify how long the cache is valid.

When a cache is used, for every RSS feed is created a local copy of RSS content in folder you specified, valid for how long you specified. When time expires a new copy of data is created. For every RSS feed is created a separate file.

If use_cache variable is false no cache is used and every call is made against original web site.

Important
All these scripts are distributed for free without any guarantees ("AS IS"). You can use or customize them upon your needs, but you have to maintain all copyright information. 2RSS.com or its author is not responsible for malfunction or other copyright issues that comes from using RSSlib. It is your responsibility to use them properly. You are not allowed to sell these scripts. For any problems, please contact us on our web site. All rights reserved to 2RSS.com and their author.

You are not allowed to remove "Powered by RSSlib" text. If you want RSSlib scripts without copyright information you can register it for $19.99 at AdvanCode.com/buy.php?prod=rsslib.

*Note for ASP pages:
1. You have to install MS XML parser available for free at msdn.microsoft.com/downloads/.
2. Part of these scripts are taken from pajhome.org.uk/crypt/md5/ (distributed under BSD license):
   A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
   Digest Algorithm, as defined in RFC 1321.
   Copyright (C) Paul Johnston 1999 - 2000.
   Updated by Greg Holt 2000 - 2001.
   Adapted for use in ASP by Ian Brennan, Cyrona Software, 2001
   (Any modifications covered by LGPL)

Updates:

  • [Jan. 11, 2005] New variable available in rsslib.php (/ .asp) to hide channel name & link. Just set display_channel_name to false (default is true => channel name is displayed) - v1.04
  • [Dec. 14, 2004] Added support for <content:encoded> - v1.03
  • [Feb. 7, 2004] Fixed a bug for JavaScript version - v1.02
  • [Oct. 25, 2003] Changed default value for caching (default is true) - v1.01
  • [Oct. 21, 2003] Initial release - v1.0

 

« Back

 

© 2003-2005 2RSS.com · Oxidev Interactive Property Terms of use