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

Permalink Leave a Comment