RORGURU.COM

Useful Information for Ruby on Rails Developers

Twitter API integration

 

30-07-2010 | Comments

We are vastly using API integration for different purposes in our application. We did several API integration like Basecamp API integration,Twitter API integration.

        We used Twitter API integration in ruzuku.com. In Twitter API integration, we can send data from our website to twitter and retrieve data from twitter website to our application by authenticating the user.


        Sample Code for Retrieving data in Twitter:

@user = User.find(xxxx)
client = Twitter::Client.new(:login = 'xxxx', :password = 'xxxxxxx')
@tweets = client.timeline_for(:user, :id = xxxx)
//* In @tweets, we got values in hash *//
@tweets.each do |tweet|
//* In tweet, we can get a single record*//
//* Now we can get the data of a particular attributes like this*//
@progress_tweet.twitterid = tweet.user.screen_name
end

Sample Code for sending data in Twitter:

#==============================================#
client.message(:post, messages, id)

#==============================================#

Comments

 

Leave a Comment

 
Name (required)
 
Email
(will not be published)
 
Website
 
Comments