twitter user tweets

May 13, 2009 at 6:02 pm (Twitter) (, , )

The following code describes the way we can fetch the tweets of the user.

I just came across this wonderful GEM to integrate TWITTER in rails.
This is called Twitter4r

Its API is available at API

Its such an easy gem to use. I thought i shall throw the steps needed for the most regular task needed….Getting the tweets of a particular user.

Install twitter4r.

require “twitter”

twitter = Twitter::Client.new(:login=>”login_name”,:password=>”password”)tweets = twitter.timeline_for(:user,:id=>”user_name_of_user_whose_tweets_you_need”)
The result is an array
The important attributes of this array-elements are:
@text – The text of this tweet
@user – The user who posted this tweet
@user.name – name of the user who posted this tweet.
@user.screen_name – screen name of the user who posted this tweet

Hope this is useful.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: