Create RSS Feed Reader Using PHP and Jquery

In this tutorial, you can create simple RSS reader with help of PHP and Jquery.

RSS reader will fetch the latest contents from the webpage using the feed url.

To get the RSS (Rich Site Summary), you will need to provide the feed url. When the form is submitted the feed url is sent to rssreader.php via http post method and show the results.

I am using zRss feed and vticker jquery plugins that fetches and sliding the latest contents from the website.

RSS READER
RSS READER

Demo Code

Add Files:-

1. index.php
2. rssreader.php
3. jquery.rssfeed.css
4. jquery.rssfeed.min.js
5. jquery.vticker.js

index.php







RSS feeds


RSS Reader


RSS FEEDS
RSS FEEDS

rssreader.php










RSSFeed - RSS feeds with vticker animation


RSS Feeds

/', $output, $matches); //regular expression to find the feed url $feedurl=$matches[1]; ?>

jquery.rssfeed.css

@charset "UTF-8";
/*
 * RSS Ticker Styling
 *
 */

body {
	margin: 1em 3em;
	font-family: Tahoma, Genevam, sans-serif;
}

.rssFeed {
	font-family: Arial, Helvetica, sans-serif;
	font-size: small;
	width: 400px;
	margin-bottom: 2em;
}
.rssFeed a {
	color: #444;
	text-decoration: none;
}
.rssFeed a:hover {
	color: #000;
	text-decoration: underline;
}

.rssHeader { padding: 0.2em 0; }

.rssBody { border: 4px solid #666; }
.rssRow h4, .rssRow p, .rssRow div {
	margin: 0;
	padding: 0.5em;
}

#ticker1 .odd { background-color: #e8e8fc; }
#ticker1 .even { background-color: #d4d4e8; }

.rssError{ color:#FF0000; font-weight:bold; text-align:center; background-color:#CCCCCC; line-height:45px; }

jquery.rssfeed.min.js

(function(l){l.fn.rssfeed=function(b,h,w){h=l.extend({limit:10,offset:1,header:!0,titletag:"h4",date:!0,dateformat:"datetime",content:!0,snippet:!0,media:!0,showerror:!0,errormsg:"",key:null,ssl:!1,linktarget:"_self",linkredirect:"",linkcontent:!1,sort:"",sortasc:!0,historical:!1},h);return this.each(function(z,q){var u=l(q),f="";h.ssl&&(f="s");u.hasClass("rssFeed")||u.addClass("rssFeed");if(null==b)return!1;0'+b.title+"
");m+='
    ';for(f=e.offset;fa?a="< 1 min":(3600>a?(a=Math.round(a/60)-1,c="min"):86400>a?(a=Math.round(a/3600)-1,c="hour"):604800>a?(a=Math.round(a/86400)-1,c="day"):(a=Math.round(a/604800)-1,c="week"),1'+g.title+"";e.date&&a&&(j[d].html+="
    "+a+"
    ");e.content&&(g=e.snippet&&""!=g.contentSnippet?g.contentSnippet:g.content,e.linkcontent&&(g=''+g+""),j[d].html+="

    "+g+"

    ");if(e.media&&0'+r.split("/").pop()+" ("+s+", ",s=Math.floor(Math.log(t)/Math.log(1024)),t=(t/Math.pow(1024,Math.floor(s))).toFixed(2)+" "+"bytes kb MB GB TB PB".split(" ")[s];c.html=y+(r+t+")")}j[d].html+="
"}}e.sort&&j.sort(function(a,c){if(e.sortasc)var b= a.sort,d=c.sort;else b=c.sort,d=a.sort;if("date"==e.sort)return new Date(b)-new Date(d);b=b.toLowerCase();d=d.toLowerCase();return bd?1:0});l.each(j,function(a){m+='
  • '+j[a].html+"
  • ";v="odd"==v?"even":"odd"});m+="
    ";l(q).html(m);l("a",q).attr("target",e.linktarget)}l.isFunction(w)&&w.call(this,u)}else h.showerror&&(d=""!=h.errormsg?h.errormsg:b.responseDetails),l(q).html('

    '+d+"

    ")})})};var p=function(b){b+="";2>b.length&& (b="0"+b);return b},x=function(b){return"Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" ")[b]}})(jQuery);

    jquery.vticker.js

    (function($){
    
    $.fn.vTicker = function(options) {
    	var defaults = {
    		speed: 700,
    		pause: 4000,
    		showItems: 3,
    		animation: '',
    		mousePause: true,
    		isPaused: false
    	};
    
    	var options = $.extend(defaults, options);
    
    	moveUp = function(obj2, height, paused){
    		if(paused) return;
    		
    		var obj = obj2.children('ul');
    		
    	    	first = obj.children('li:first').clone(true);
    		
        		obj.animate({top: '-=' + height + 'px'}, options.speed, function() {
            		$(this).children('li:first').remove();
    	        	$(this).css('top', '0px');
            	});
    		
    		if(options.animation == 'fade') {
    			obj.children('li:first').fadeOut(options.speed);
    			obj.children('li:last').hide().fadeIn(options.speed);
    		}
    
    	    	first.appendTo(obj);
    	};
    	
    	return this.each(function() {
    		var obj = $(this);
    		var maxHeight = 0;
    		var itempause = options.isPaused;
    
    		obj.css({overflow: 'hidden', position: 'relative'})
    			.children('ul').css({position: 'absolute', margin: 0, padding: 0})
    			.children('li').css({margin: 0, padding: 0});
    
    		obj.children('ul').children('li').each(function(){
    
    			if($(this).height() > maxHeight) {
    				maxHeight = $(this).height();
    			}
    		});
    
    		obj.children('ul').children('li').each(function() {
    			$(this).height(maxHeight);
    		});
    
    		obj.height(maxHeight * options.showItems);
    		
        		var interval = setInterval(function(){ moveUp(obj, maxHeight, itempause); }, options.pause);
    		
    		if (options.mousePause)
    		{
    			obj.bind("mouseenter",function() {
    				itempause = true;
    			}).bind("mouseleave",function() {
    				itempause = false;
    			});
    		}
    	});
    };
    })(jQuery);
    SHARE: