Tuesday, January 3, 2012

SSIS: How to pull Tweets from Twitter?

Today I learn a very simple way to pull tweets from Twitter using SSIS. It is very easy to read RSS feed of a twitter user using following mechanism. Simply navigate to the following web address.

http://api.twitter.com/1/statuses/user_timeline.rss?screen_name=?

The only thing we have to do is to place the twitter user id to the screen_name parameter. So, I put my twitter id (vksingh24) and go the following in my screen.

http://api.twitter.com/1/statuses/user_timeline.rss?screen_name=vksingh24

Now my next goal is to pull this information from Twitter periodically using SSIS and store this to a table. The tweets data stored will be used by different applications (windows, web and mobile) of mine.

I created an SSIS package and added a Data Flow Task in Control Flow tab. I have added two components Script Component and Row Sampling in the Data Flow tab.

I have used Script Component as a Source in my SSIS package. I have added two output columns (TwitterFeed and TwitDate) with the data type as string(DT_STR).

The next step is to write some piece of code to pull the Twitter RSS Feed. Before we go ahead and do this few points we have to understand. The .NET framework version 3.5 provides us namespace System.ServiceModel.Syndication to read the RSS feed. My code snippet is using .NET Framework 3.5 to read the above shown RSS Feed. Here is my code snippet in Script component.

After setting up my script component, I added Row Sampling component. I actually have no use of this component, I just wanted to pass the data from Script Component to Row Sampling. I have added a Data Viewer between Script Component and Row Sampling. After setting up all this I run my SSIS package and Data Viewer shows me all the Tweets and its published date.

Now, my proof of concept was ready and I took this approach to design my SSIS package which runs every hour and pull the tweets of the Twitter users.

I hope you like this post.

If you want to explore with this SSIS package, please visit the Download Zone to get hands on the source code

Related Article:

Popular Posts

Real Time Web Analytics