Wednesday, December 21, 2011

SSIS: Read public data of Twitter Users

Social networking is great tool of this decade and every one want to learn and explore this media. Google +, Facebook, Twitter, Linkedin etc., there are many players in the race to get your attention and want you to experiment with them.

Twitter is one of the leading player among them. There are many mechanisms for pulling data from Twitter profiles. Twitter itself provides Twitter API and Twitter Widgets to do the same. We have other customized tools such as Tweet-SQL to pull the twitter feed/data. There are bunch of Twitter tools available which you can use.

When it comes to SSIS we can use one of the simplest things on offer to pull Twitter Feed or public data of a Twitter user. For example if you want to see the public data of my Twitter account you can navigate to the below link

http://api.twitter.com/1/users/show.xml?screen_name=vksingh24

This shows me following xml feed in my browser

You can replace the screen_name with your own twitter user name and see the results in your browser. We can use this URL to pull the public data of a Twitter user.

So I want to pull count of Followers and count of Friends of a twitter user from his public profile.

To do so, I created an SSIS package and created a package level variable (TwitterScreenName). This variable stores the screen name of twitter user whose public information (Friend and Follower count) I want to extract.

I added a script task “Read Twitter User Data” and launch the Script Task editor box. I am using the variable I created in Screen1 as a ReadOnlyVariable.

The Script Task has following code snippet. The code snippet reads the Friends and Followers count from the xml feed return from the Twitter API call.

After running the SSIS package I saw the Friends and Followers counts of mine Twitter account. (I know I am not very active on Twitter).

One can extract all the public information from the XML Feed such as when the twitter ID was created, profile picture location, latest feed etc.

Using this approach we can have a solution where we can pull the latest public twitter data of a twitter profile (person or organization or event etc) and store that in a table which we can latter use to show in reports or web pages as needed.

Twitter has put Rate Limitation on this approach. A twitter user profile data can be accessed 150 times per hour. An IP address can pull the twitter users profile data 150 times per hour.

I hope you like this post and mark your reaction in the footer. Thanks for reading this post

Popular Posts

Real Time Web Analytics