Find file
Fetching contributors…
Cannot retrieve contributors at this time
21 lines (16 sloc) 776 Bytes
require 'rubygems'
require File.dirname(__FILE__) + '/../lib/typhoeus.rb'
require 'json'
class Twitter
include Typhoeus
remote_defaults :on_success => lambda {|response| JSON.parse(response.body)},
:on_failure => lambda {|response| puts "error code: #{response.code}"},
:base_uri => ""
define_remote_method :search, :path => '/search.json'
define_remote_method :trends, :path => '/trends/:time_frame.json'
tweets = => {:q => "railsconf"})
trends = Twitter.trends(:time_frame => :current)
# and then the calls don't actually happen until the first time you
# call a method on one of the objects returned from the remote_method
puts tweets.keys # it's a hash from parsed JSON