/usr/share/doc/ruby-em-http-request/examples/oauth-tweet.rb is in ruby-em-http-request 1.1.5-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | $: << 'lib' << '../lib'
require 'em-http'
require 'em-http/middleware/oauth'
require 'em-http/middleware/json_response'
require 'pp'
OAuthConfig = {
:consumer_key => '',
:consumer_secret => '',
:access_token => '',
:access_token_secret => ''
}
EM.run do
# automatically parse the JSON response into a Ruby object
EventMachine::HttpRequest.use EventMachine::Middleware::JSONResponse
# sign the request with OAuth credentials
conn = EventMachine::HttpRequest.new('http://api.twitter.com/1/statuses/home_timeline.json')
conn.use EventMachine::Middleware::OAuth, OAuthConfig
http = conn.get
http.callback do
pp http.response
EM.stop
end
http.errback do
puts "Failed retrieving user stream."
pp http.response
EM.stop
end
end
|