Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twitter/Facebook API for Ruby

I want to write a Ruby application through which:

  1. I can submit tweets to twitter.
  2. I can submit a post to facebook.
  3. I can manage real-time stats of tweets

Is there any twitter/facebook api for Ruby?

like image 763
RKh Avatar asked Dec 05 '22 04:12

RKh


2 Answers

I use the Twitter gem and am quite happy with it.

For Facebook, there is the Facebooker gem.

like image 166
Trevor Avatar answered Jan 01 '23 21:01

Trevor


Streams of tweets:

Tweetmon is a great gem for keeping real-time track of tweets. Here's an example of using it to get a stream of tweets on a specific keyword

 #!/usr/local/bin/ruby 

 if ARGV.size==1
   keyword = ARGV.shift
 else
   puts 'tweetmon usage: tweetmon <keyword>'
   exit 1
 end

 require 'yaml'
 require 'rubygems'
 require 'tweetstream'

 config = YAML::load(File.open(File.expand_path('~/.twitter')))
 user =config['username']
 password =config['password']

 TweetStream::Client.new(user,password).track(keyword) do |status|  
   puts "[#{status.created_at}-#{status.user.screen_name}] #{status.text}"
 end  

To use this gem you need: gem sources -a http://gems.github.com gem install intridea-tweetstream

To submit a tweet is just a HTTP POST - doesn't need any extra libraries to do this.

like image 41
Dafydd Rees Avatar answered Jan 01 '23 21:01

Dafydd Rees