Sha256: e2eaae9e754c00bd216c36b21086be40d977908893e6896e6e44bc45be5dea4d

Contents?: true

Size: 776 Bytes

Versions: 15

Compression:

Stored size: 776 Bytes

Contents

require File.dirname(__FILE__) + '/../lib/typhoeus.rb'
require 'rubygems'
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   => "http://search.twitter.com"

  define_remote_method :search, :path => '/search.json'
  define_remote_method :trends, :path => '/trends/:time_frame.json'
end

tweets = Twitter.search(:params => {: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

Version data entries

15 entries across 15 versions & 4 rubygems

Version Path
abhay-typhoeus-0.0.22 examples/twitter.rb
tech-angels-typhoeus-0.1.36 examples/twitter.rb
typhoeus-0.1.29 examples/twitter.rb
gravis-typhoeus-0.1.36 examples/twitter.rb
typhoeus-0.1.28 examples/twitter.rb
gravis-typhoeus-0.1.35 examples/twitter.rb
gravis-typhoeus-0.1.34 examples/twitter.rb
gravis-typhoeus-0.1.33 examples/twitter.rb
gravis-typhoeus-0.1.32 examples/twitter.rb
gravis-typhoeus-0.1.31 examples/twitter.rb
gravis-typhoeus-0.1.30 examples/twitter.rb
gravis-typhoeus-0.1.29 examples/twitter.rb
typhoeus-0.1.27 examples/twitter.rb
typhoeus-0.1.26 examples/twitter.rb
typhoeus-0.1.25 examples/twitter.rb