Livecommunity powered by sixgroups.com
  ABOUT MASHUP CAMP WIKI BEST MASHUP CONTEST NEWS SPONSORS CONTACT TV BLOG WHO'S COMING?

RoR and Twitter Mashup

From MashupCamp

Jump to: navigation, search

In this section, we will learn how to integrate Twitter statuses into our web site.

Contents

Twitter4R Library

RubyGems comes to the rescue and makes it easy to install the Twitter4R library. Simply open a command window and type:

 gem install twitter4r

If that doesn't work, download the tarball or zip packages manually:

There is quite a lot of documentation on Twitter4R. Please see:

* http://twitter4r.rubyforge.org/rdoc/
* http://twitter4r.rubyforge.org/articles/

Rails Twitter4R Files

Now let's put Twitter in our web site.

Main Files

First get the Twitter4R Rails files add them to your Rails home directory:

* http://rubyforge.org/frs/download.php/23274/twitter4rails.post-0_2_4.zip

Next, make these changes:

Customize Twitter for Rails Application

Copy config/twitter.yml.conf to config/twitter.yml and edit it as needed.

Append and uncomment the following to your config/environment.rb as is applicable to your Rails application:

#  Twitter::Client.configure do |conf|
#    # We can set Twitter4R to use <tt>:ssl</tt> or <tt>:http</tt> to connect to the Twitter API.
#    # Defaults to <tt>:ssl</tt>
#    conf.protocol = :ssl
#
#    # We can set Twitter4R to use another host name (perhaps for internal
#    # testing purposes).
#    # Defaults to 'twitter.com'
#    conf.host = 'twitter.com'
#
#    # We can set Twitter4R to use another port (also for internal 
#    # testing purposes).
#    # Defaults to 443
#    conf.port = 443
#    
#    # We can set proxy information for Twitter4R
#    # By default all following values are set to <tt>nil</tt>.
#    conf.proxy_host = 'myproxy.host'
#    conf.proxy_port = 8080
#    conf.proxy_user = 'myuser'
#    conf.proxy_pass = 'mypass'
#
#    # We can also change the User-Agent and X-Twitter-Client* HTTP headers
#    conf.user_agent = 'MyAppAgentName'
#    conf.application_name = 'MyAppName'
#    conf.application_version = 'v1.5.6'
#    conf.application_url = 'http://myapp.url'
# 
#    # Twitter (not Twitter4R) will have to setup a source ID for your application to get it 
#    # recognized by the web interface according to your preferences.
#    # To see more information how to go about doing this, please referen to the following thread:
#    # http://groups.google.com/group/twitter4r-users/browse_thread/thread/c655457fdb127032
#    conf.source = "your-source-id-that-twitter-recognizes"
#  
#  end