Jquery + YQL = Awesome RSS Feeding without server side proxy script :-D!

So I have been struggling for the past month trying to get a Perl CGI script that acts as a proxy to work on certain servers. The client only supports/allowed perl (as far as i knew) and didn’t allow it to output data to a browser for some reason. So you can see my dilemma. I tried various means. Worked with their IT team, etc… I kept trying to find alternative methods. I knew JSONP was an option but it’s not like RSS feeds are in JSON or are coming from a JSONP server. Finally someone told me about YQL. In short, I am pretty impressed. I essentially used it as a proxy and XML -> JSON converter. The script in JQuery is really short and goes like this:

var maxEntries = 5; // if 0 then there will be no limit

function slug(str){
 return str.replace(/\s/g,'-').replace(/[^a-zA-Z0-9\-]/g,'').toLowerCase();
 * This function appends rss feed items to divs with the same slug
 * Name is the title of the feed, when slugged i use it as a div id
 * File is the rss feed
function newFeed(name, file) {
 $.getJSON("http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20xml%20where%20url%3D%22"+encodeURIComponent(file)+"%22&format=json&callback=?", function(d) {
  var count = 0;
  //grab ever rss item from the json result request
  $(d.query.results.rss.channel.item).each(function() {
    //if set up to be infinite or the limit is not reached, keep grabbing items
    if(maxEntries == 0 || maxEntries>count){
     var title = this.title;
     var link = this.link;
     var description = this.description;
     var pubDate = this.pubDate;
     // Format however you want, I only went for link and title
     var anItem = "<a href='"+link+"' target='_blank'>"+title+"</a><br>";
     //append to the div

I hope you guys find this useful. It made my life a ton easier to deal with. Coming soon… I’ll show you how to convert Andrew Sellick’s Sexy Slide Menu for Prototype to JQuery! WOO!


One Response to “Jquery + YQL = Awesome RSS Feeding without server side proxy script :-D!”

  1. Fatal error: Uncaught Error: Call to undefined function mysql_query() in /home/blackto/public_html/wp-content/plugins/comment-rating/comment-rating.php:219 Stack trace: #0 /home/blackto/public_html/wp-content/plugins/comment-rating/comment-rating.php(457): ckrating_get_rating('760') #1 /home/blackto/public_html/wp-includes/class-wp-hook.php(300): ckrating_comment_class(Array, '', '760', Object(WP_Comment)) #2 /home/blackto/public_html/wp-includes/plugin.php(203): WP_Hook->apply_filters(Array, Array) #3 /home/blackto/public_html/wp-includes/comment-template.php(525): apply_filters('comment_class', Array, '', '760', Object(WP_Comment), NULL) #4 /home/blackto/public_html/wp-includes/comment-template.php(430): get_comment_class('', Object(WP_Comment), NULL) #5 /home/blackto/public_html/wp-includes/class-walker-comment.php(270): comment_class('', Object(WP_Comment)) #6 /home/blackto/public_html/wp-includes/class-walker-comment.php(195): Walker_Comment->comment(Object(WP_Comment), 1, Array) #7 /home/blackto/public_html/wp-inclu in /home/blackto/public_html/wp-content/plugins/comment-rating/comment-rating.php on line 219