Skip to main content

I needed to retrieve the first two posts from a Facebook page's wall, and decided against using a full-feature plugin for such a small request. Since direct loading of cross-domain RSS feeds is not permitted and I want to avoid using proxies, Yahoo Pipes was the best solution. I created a Pipe using its 'Fetch Feed' module, and simply let it load the Facebook RSS feed URL. From the generated link, I was able to treat the URL like a local file.

/*Using Yahoo Pipes' 'Fetch Feed' feature to enable cross-domain RSS parsing:
http://pipes.yahoo.com/ */
var itemsToFetch = 2;

//this is the url generated by Pipes
var rssURL = "http://pipes.yahoo.com/pipes/pipe.run?_id=8bdb8ca5bc1f26650d37edb780a0107d&_render=rss";

$.ajax({
    type: "GET",
    url: rssURL,
    dataType: "xml",
    success: function (xml) {
        //create an ul in the empty #feed-holder <div>
        $('#feed-holder').html('<ul></ul>');
        for (i = 0; i < itemsToFetch; i++) {
            var $rssItem = $(xml).find('item:eq(' + i + ')');
            var title = $rssItem.find('title').text();
            var link = $rssItem.find('link').text();
            var date = $rssItem.find('pubDate').text();
            $('#feed-holder ul').append('<li> <a href="' + link + '" target="_blank"><div class="linkbox"><img src="http://placehold.it/28x28"/><div class="fb-date">' + date + '</div><div class="fb-title">' + title + '</div></a></li>');
        }
    }
});