Twitter/Facebook API for Ruby - ruby

I want to write a Ruby application through which:
I can submit tweets to twitter.
I can submit a post to facebook.
I can manage real-time stats of tweets
Is there any twitter/facebook api for Ruby?

I use the Twitter gem and am quite happy with it.
For Facebook, there is the Facebooker gem.

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.

The Twitter API is a RESTful web service. It's completely language agnostic. Use whatever language you want.
Not sure about Facebook.

Two more libraries that didn't get mentioned yet:
twitter4r: http://twitter4r.rubyforge.org/
Twibot: http://cjohansen.no/en/ruby/twibot_a_microframework_for_twitter_bots_in_ruby

If you're inclined to retain more control over how you use the Twitter and Facebook APIs you can use the Wrest gem.
Take a look at the facebook (http://is.gd/bJspX) and twitter (http://is.gd/bJsqV) examples.
Also, while both the Twitter and Facebook APIs are HTTP APIs, they are not RESTful despite their claims to the contrary.

I would use this gem, it's really helpful https://github.com/moomerman/twitter_oauth
or just gem install twitter_oauth

MiniFB https://github.com/appoxy/mini_fb is excellent for Facebook API. But in both APIs you can do everything through HTTPParty and OAuth.

Related

in Google Fusion Tables, how do I make a PUT request with Ruby?

Looking at Google Fusion Tables API, it says that Fusion Tables styles can be updated via PUT requests.
Is it possible to make such a PUT request with Ruby?
There's the Net::HTTP library:
require 'net/http'
google_api = Net::HTTP.new 'www.googleapis.com'
google_api.get '/fusiontables/v1/tables'
This is a simple homemade solution. Maybe you'll have some use for a more extensive framework to access the google api. A quick search on 'google api ruby gem' uncovered this gem.
http://www.ruby-doc.org/stdlib-1.9.3/libdoc/net/http/rdoc/Net/HTTP.html
You can use HTTP POST to do INSERT or UPDATE. Check the Google online information. There is also a Ruby library

How do I get Twitter follow request with the Tweetstream Ruby gem?

According to this Ars Technica tutorial, "the streaming API makes it easy to detect when the user gets a new follower. To detect follow event objects, look for the "event" key and check if it has the string "follow" as the value."
http://arstechnica.com/information-technology/2010/04/tutorial-use-twitters-new-real-time-stream-api-in-python/2/
The tweetstream gem supposedly exposes all methods from the API. However I can't figure out, how to get to those follow requests!
Any ideas?
The tweetstream gem is fairly complete, but sometimes you need to delve into the source to find stuff:
client.on_event(:follow) do |event|
p event[:source][:screen_name]
end
https://github.com/intridea/tweetstream/blob/master/lib/tweetstream/client.rb#L375 :)

Api for google-api-client gem

How do I get the api of this gem? I could currently get the name and email of the user with
google_client.execute!(:api_method => GoogleLogic.get_google_oauth2.userinfo.get).data.name
google_client.execute!(:api_method => GoogleLogic.get_google_oauth2.userinfo.get).data.email
but no where are these methods written in the official page of this gem
http://code.google.com/p/google-api-ruby-client/
Since the ruby client is generated dynamically, it may not have API docs. You can see the API definition here:
https://www.googleapis.com/discovery/v1/apis/oauth2/v1/rest
It might be useful to you to see what methods/attributes are generated in the library.
Not sure if this is relevant anymore, but I found the documentation on the github page quite useful:
https://github.com/google/google-api-ruby-client
And also the samples:
https://github.com/google/google-api-ruby-client-samples
Lastly, the developers console in google is very useful.
http://console.developers.google.com/

Ruby on Rails with chargify

I want to integrate chargify to my rails app. I have user object and I want the user to be able to subscribe for one month and update the boolean column on user object. I prefer to use the API not hosted pages. How can I do that?
Is there any example for chargify on ruby on rails for handling subscriptions but with details about mvc for newbies?
Based on this thread and the Googles it looks like there is not a whole lot out there.
You could try looking at the Rails 2 example here and converting it or use the gem here (gem "chargify", "~> 0.3.0").
I know none of this is aimed at newbies but the info seems to sparse.
This might get you going. It seems that Chartify itself is written in Rails, and therfore their API is ruby code, which you can use...

Is there a Twitter Streams API for Ruby?

Does anyone know of a Ruby gem or plugin that provides a simple interface to the Twitter Steams API?
Try TweetStream: https://github.com/intridea/tweetstream
Twitter Gem has added streaming functionality.
you can check that out

Resources