Sha256: d5939cd75bcc098ef368f35e8e6a37b806e5d82429e28f2c2ce262c96f680d84

Contents?: true

Size: 1001 Bytes

Versions: 140

Compression:

Stored size: 1001 Bytes

Contents

dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
require File.join(dir, 'httparty')
require 'pp'
config = YAML::load(File.read(File.join(ENV['HOME'], '.twitter')))

class Twitter
  include HTTParty
  base_uri 'twitter.com'
  
  def initialize(u, p)
    @auth = {:username => u, :password => p}
  end
  
  # which can be :friends, :user or :public
  # options[:query] can be things like since, since_id, count, etc.
  def timeline(which=:friends, options={})
    options.merge!({:basic_auth => @auth})
    self.class.get("/statuses/#{which}_timeline.json", options)
  end
  
  def post(text)
    options = { :query => {:status => text}, :basic_auth => @auth }
    self.class.post('/statuses/update.json', options)
  end
end

twitter = Twitter.new(config['email'], config['password'])
pp twitter.timeline
# pp twitter.timeline(:friends, :query => {:since_id => 868482746})
# pp twitter.timeline(:friends, :query => 'since_id=868482746')
# pp twitter.post('this is a test of 0.2.0')

Version data entries

140 entries across 140 versions & 25 rubygems

Version Path
nutshell-crm-0.0.4 vendor/bundle/gems/httparty-0.8.1/examples/twitter.rb
nutshell-crm-0.0.3 vendor/bundle/gems/httparty-0.8.1/examples/twitter.rb
nutshell-crm-0.0.2 vendor/bundle/gems/httparty-0.8.1/examples/twitter.rb
nutshell-crm-0.0.1 vendor/bundle/gems/httparty-0.8.1/examples/twitter.rb
httparty-0.8.1 examples/twitter.rb
httparty-0.8.0 examples/twitter.rb
httparty2-0.7.10 examples/twitter.rb
httparty-0.7.8 examples/twitter.rb
httparty-0.7.7 examples/twitter.rb
httparty-0.7.6 examples/twitter.rb
httparty-0.7.4 examples/twitter.rb
httparty-0.7.3 examples/twitter.rb
httparty-0.7.2 examples/twitter.rb
httparty-0.7.0 examples/twitter.rb
spreedly-1.3.4 vendor/httparty/examples/twitter.rb
spreedly-1.3.3 vendor/httparty/examples/twitter.rb
dnclabs-httparty-0.6.1.2010090201 examples/twitter.rb
bartzon-httparty-0.6.1 examples/twitter.rb
httparty-0.6.1 examples/twitter.rb
httparty-0.6.0 examples/twitter.rb