Monday, 11 March 2013

Fetch Rss feeds into SharePoint List

I  had been into a scenario where I need to search the results from one of the Rss feeds into SharePoint search results page.

This means the data from this Rss feeds had to be into SharePoint content database and then SharePoint search crawler will crawl the content and made the content search able into the results page.

So I came up with a design of fetching the data from the Rss feeds into the SharePoint list in an hourly basis and will display the top 10 results into the home page and user can search on this Rss feeds.

In this design I need
1. Rss Feed link (http://feeds.bbci.co.uk/news/rss.xml)
2. SharePoint Custom list which will store the content from Rss feed.
3.Content Editor web part (CEWP) to display the top 10 results in to the home page.
4.Fetch the latest results into the SharePoint list in every one hour.

I am using SPServices to add/update the Rss Feeds into SharePoint list. In order to know more on SPServices and how to perform CRUD operations, Please visit my blog on CRUD operations using SPServices.

Step1: Fetch the Rss Feeds

At First, Created  a Custom List called RSS Feed with the custom columns Content, PublishedDate, FeedLink and Title.

So what I am doing here is, Calling Google feed api using  jQuery ajax to fetch the Rss feed by passing query parameters, q as Rss Feed url link and num to -1 to fetch all the results back into json object and then iterating each object and storing into SharePoint list.

Step2:Store the feeds into SharePoint List

Step3: Display the content from SharePoint List in the home page using CEWP.

Step4: Fetch the latest feed in every hour.

Hope you find this blog useful.

Cheers,
Isha Jain

4 comments:

  1. Hi Isha,
    when adding items to the list, how do you handle possible duplicate entries?
    Thanks!
    Phu

    ReplyDelete
    Replies
    1. Hi Phu,

      Below function link will help to check already existing entries in the list. This function will only add the non-duplicate entries into the list.

      https://gist.github.com/ishajain/5428131

      Delete
  2. Hi, this is a great article and the only one I found that does this without any custom server side solution deployment. However, I am having a hard time getting it to work.. I have added all the scripts mentioned above to my page, created RSS Feed list with the mentioned fields and added the jquery libraries (jquery + SPservices). I also validated that jquery is loaded by testing with the following two alerts:
    $(document).ready(function() {
    alert("jQuery");
    alert($().SPServices.SPGetCurrentSite());
    });

    however, nothing gets stored in my RSS Feed list... and no errors on page either... any ideas how I could troubleshoot this? I have tried using guid ID for the list instead of name but still nothing happens. Thanks.

    ReplyDelete
  3. Apologies for late reply.

    Try first without the rotation function to see if it loads the feeds. Comment out the rotation function and call the function fetchRSSFeed() outside of it.

    ReplyDelete