Sha256: c92255c862e7e1de21abfd883a30608fea7e4eaf41e3fc995a3d0a5d9958024f

Contents?: true

Size: 783 Bytes

Versions: 2

Compression:

Stored size: 783 Bytes

Contents

$: << 'lib' << '../lib'

require 'z-http'
require 'z-http/middleware/oauth'
require 'z-http/middleware/json_response'

require 'pp'

OAuthConfig = {
  :consumer_key     => '',
  :consumer_secret  => '',
  :access_token     => '',
  :access_token_secret => ''
}

ZMachine.run do
  # automatically parse the JSON response into a Ruby object
  ZMachine::HttpRequest.use ZMachine::Middleware::JSONResponse

  # sign the request with OAuth credentials
  conn = ZMachine::HttpRequest.new('http://api.twitter.com/1/statuses/home_timeline.json')
  conn.use ZMachine::Middleware::OAuth, OAuthConfig

  http = conn.get
  http.callback do
    pp http.response
    ZMachine.stop
  end

  http.errback do
    puts "Failed retrieving user stream."
    pp http.response
    ZMachine.stop
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
z-http-request-0.2.0 examples/oauth-tweet.rb
z-http-request-0.1.0 examples/oauth-tweet.rb